Skip to content

Commit

Permalink
KnownDirectivesRule-test: remove dependency on harness schema (#3176)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Jun 14, 2021
1 parent 0b7625f commit 632c0d8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
26 changes: 24 additions & 2 deletions src/validation/__tests__/KnownDirectivesRule-test.ts
Expand Up @@ -6,10 +6,17 @@ import { buildSchema } from '../../utilities/buildASTSchema';

import { KnownDirectivesRule } from '../rules/KnownDirectivesRule';

import { expectValidationErrors, expectSDLValidationErrors } from './harness';
import {
expectValidationErrorsWithSchema,
expectSDLValidationErrors,
} from './harness';

function expectErrors(queryStr: string) {
return expectValidationErrors(KnownDirectivesRule, queryStr);
return expectValidationErrorsWithSchema(
schemaWithDirectives,
KnownDirectivesRule,
queryStr,
);
}

function expectValid(queryStr: string) {
Expand All @@ -24,6 +31,21 @@ function expectValidSDL(sdlStr: string, schema?: GraphQLSchema) {
expectSDLErrors(sdlStr, schema).to.deep.equal([]);
}

const schemaWithDirectives = buildSchema(`
type Query {
dummy: String
}
directive @onQuery on QUERY
directive @onMutation on MUTATION
directive @onSubscription on SUBSCRIPTION
directive @onField on FIELD
directive @onFragmentDefinition on FRAGMENT_DEFINITION
directive @onFragmentSpread on FRAGMENT_SPREAD
directive @onInlineFragment on INLINE_FRAGMENT
directive @onVariableDefinition on VARIABLE_DEFINITION
`);

const schemaWithSDLDirectives = buildSchema(`
directive @onSchema on SCHEMA
directive @onScalar on SCALAR
Expand Down
7 changes: 0 additions & 7 deletions src/validation/__tests__/harness.ts
Expand Up @@ -134,14 +134,7 @@ export const testSchema: GraphQLSchema = buildSchema(`
query: QueryRoot
}
directive @onQuery on QUERY
directive @onMutation on MUTATION
directive @onSubscription on SUBSCRIPTION
directive @onField on FIELD
directive @onFragmentDefinition on FRAGMENT_DEFINITION
directive @onFragmentSpread on FRAGMENT_SPREAD
directive @onInlineFragment on INLINE_FRAGMENT
directive @onVariableDefinition on VARIABLE_DEFINITION
`);

export function expectValidationErrorsWithSchema(
Expand Down

0 comments on commit 632c0d8

Please sign in to comment.