-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aba2bbb
commit 97b9a8f
Showing
17 changed files
with
832 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/validation/__tests__/NoUnusedFragmentVariablesRule-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { describe, it } from 'mocha'; | ||
|
||
import { NoUnusedFragmentVariablesRule } from '../rules/NoUnusedFragmentVariablesRule'; | ||
|
||
import { expectValidationErrors } from './harness'; | ||
|
||
function expectErrors(queryStr: string) { | ||
return expectValidationErrors(NoUnusedFragmentVariablesRule, queryStr); | ||
} | ||
|
||
function expectValid(queryStr: string) { | ||
expectErrors(queryStr).toDeepEqual([]); | ||
} | ||
|
||
describe('Validate: No unused variables', () => { | ||
it('fragment defined arguments are not unused variables', () => { | ||
expectValid(` | ||
query Foo { | ||
...FragA | ||
} | ||
fragment FragA($a: String) on Type { | ||
field1(a: $a) | ||
} | ||
`); | ||
}); | ||
|
||
it('defined variables used as fragment arguments are not unused variables', () => { | ||
expectErrors(` | ||
query Foo($b: String) { | ||
...FragA(a: $b) | ||
} | ||
fragment FragA($a: String) on Type { | ||
field1 | ||
} | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.