Skip to content

Commit 9beb1ce

Browse files
committed
passing all test up to and including aliases
1 parent 57a8cd8 commit 9beb1ce

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

test/analysis/typeComplexityAnalysis.test.ts

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ describe('Test getQueryTypeComplexity function', () => {
172172
let variables: any | undefined;
173173
describe('Calculates the correct type complexity for queries', () => {
174174
test('with one feild', () => {
175-
query = `uery { scalars { num } }`;
175+
query = `query { scalars { num } }`;
176176
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(2); // Query 1 + Scalars 1
177177
});
178178

@@ -181,22 +181,22 @@ describe('Test getQueryTypeComplexity function', () => {
181181
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(3); // Query 1 + scalars 1 + test 1
182182
});
183183

184-
xtest('with one level of nested fields', () => {
184+
test('with one level of nested fields', () => {
185185
query = `query { scalars { num, test { name } } }`;
186186
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(3); // Query 1 + scalars 1 + test 1
187187
});
188188

189-
xtest('with multiple levels of nesting', () => {
189+
test('with multiple levels of nesting', () => {
190190
query = `query { scalars { num, test { name, scalars { id } } } }`;
191191
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(4); // Query 1 + scalars 1 + test 1 + scalars 1
192192
});
193193

194-
xtest('with aliases', () => {
195-
query = `query { foo: scalar { num } bar: scalar { id }}`;
194+
test('with aliases', () => {
195+
query = `query { foo: scalars { num } bar: scalars { id }}`;
196196
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(3); // Query 1 + scalar 1 + scalar 1
197197
});
198198

199-
xtest('with all scalar fields', () => {
199+
test('with all scalar fields', () => {
200200
query = `query { scalars { id, num, float, bool, string } }`;
201201
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(2); // Query 1 + scalar 1
202202
});
@@ -304,22 +304,6 @@ describe('Test getQueryTypeComplexity function', () => {
304304
});
305305

306306
// todo: directives @skip, @include and custom directives
307-
308-
// todo: expand on error handling
309-
xtest('Throws an error if for a bad query', () => {
310-
query = `query { hello { hi } }`; // type doesn't exist
311-
expect(() => getQueryTypeComplexity(parse(query), variables, typeWeights)).toThrow(
312-
'Error'
313-
);
314-
query = `query { hero(episode: EMPIRE){ starship } }`; // field doesn't exist
315-
expect(() => getQueryTypeComplexity(parse(query), variables, typeWeights)).toThrow(
316-
'Error'
317-
);
318-
query = `query { hero(episode: EMPIRE) { id, name }`; // missing a closing bracket
319-
expect(() => getQueryTypeComplexity(parse(query), variables, typeWeights)).toThrow(
320-
'Error'
321-
);
322-
});
323307
});
324308

325309
xdescribe('Calculates the correct type complexity for mutations', () => {});

0 commit comments

Comments
 (0)