Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KnownDirectivesRule-test: remove dependency on harness schema #3176

Merged
merged 1 commit into from Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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