Skip to content

Commit b24fcb9

Browse files
committed
fixed tests with variables
1 parent cc97c8e commit b24fcb9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/analysis/typeComplexityAnalysis.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const typeWeights: TypeWeightObject = {
169169

170170
xdescribe('Test getQueryTypeComplexity function', () => {
171171
let query = '';
172-
const variables: any | undefined = undefined;
172+
let variables: any | undefined;
173173
describe('Calculates the correct type complexity for queries', () => {
174174
test('with one feild', () => {
175175
query = `Query { scalars { num } }`;
@@ -207,6 +207,7 @@ xdescribe('Test getQueryTypeComplexity function', () => {
207207
query = `Query { human(id: 1) { id, name, appearsIn } }`;
208208
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(3); // Query 1 + human/character 1 + appearsIn/episode
209209
// argument passed in as a variable
210+
variables = { ep: 'EMPIRE' };
210211
query = `Query varibaleQuery ($ep: Episode){ hero(episode: $ep) { id, name } }`;
211212
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(2); // Query 1 + hero/character 1
212213
});
@@ -263,6 +264,7 @@ xdescribe('Test getQueryTypeComplexity function', () => {
263264
test('with lists detrmined by arguments and variables', () => {
264265
query = `Query {reviews(episode: EMPIRE, first: 3) { stars, commentary } }`;
265266
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(4); // 1 Query + 3 reviews
267+
variables = { first: 3 };
266268
query = `Query queryVaribales($first: Int) {reviews(episode: EMPIRE, first: $first) { stars, commentary } }`;
267269
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(4); // 1 Query + 3 reviews
268270
});

0 commit comments

Comments
 (0)