/* @flow */

import { SchemaComposer } from '../..';

describe('github issue #262: SchemaComposer fails to map enum values in field directives', () => {
  it('check `extend type`', async () => {
    const sc = new SchemaComposer(`
      directive @auth(permissions: [CrudPermissions]) on OBJECT | FIELD_DEFINITION

      """ @model """
      type Note {
        id: ID!
        title: String! @auth(permissions: [CREATE, READ])
      }
      
      enum CrudPermissions {
        CREATE
        READ
        UPDATE
        DELETE
      }
    `);

    expect(sc.getOTC('Note').getFieldDirectiveByName('title', 'auth')).toEqual({
      permissions: ['CREATE', 'READ'],
    });
  });
});

@@ -161,22 +161,8 @@
 heck
- %60extend type%60
 ', a
@@ -174,16 +174,16 @@
 () =%3E %7B%0A
+
     cons
@@ -650,15 +650,577 @@
 '%5D,%0A
-
     %7D);
+%0A%0A    expect(%0A      sc.toSDL(%7B%0A        include: %5B'Note'%5D,%0A        exclude: %5B'String', 'ID', 'Boolean', 'Float', 'Int'%5D,%0A        omitDescriptions: true,%0A      %7D)%0A    ).toMatchInlineSnapshot(%60%0A      %22directive @auth(permissions: %5BCrudPermissions%5D) on OBJECT %7C FIELD_DEFINITION%0A%0A      directive @specifiedBy(%0A        url: String!%0A      ) on SCALAR%0A%0A      enum CrudPermissions %7B%0A        CREATE%0A        READ%0A        UPDATE%0A        DELETE%0A      %7D%0A%0A      type Note %7B%0A        id: ID!%0A        title: String! @auth(permissions: %5B%5C%5C%22CREATE%5C%5C%22, %5C%5C%22READ%5C%5C%22%5D)%0A      %7D%22%0A    %60);
 %0A  %7D

check toSDL method