Skip to content

Commit f320dac

Browse files
committed
added a test for mutations
1 parent ba2f95e commit f320dac

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/analysis/typeComplexityAnalysis.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ describe('Test getQueryTypeComplexity function', () => {
163163
},
164164
},
165165
},
166+
mutation: {
167+
weight: 10,
168+
fields: {
169+
createReview: { resolveTo: 'review' },
170+
},
171+
},
166172
episode: {
167173
// enum
168174
weight: 0,
@@ -915,7 +921,19 @@ describe('Test getQueryTypeComplexity function', () => {
915921
// TODO: directives @skip, @include and custom directives
916922
});
917923

918-
xdescribe('Calculates the correct type complexity for mutations', () => {});
924+
describe('Calculates the correct type complexity for mutations', () => {
925+
test('simple mutation', () => {
926+
variables = { review: { stars: 5, commentary: 'good' } };
927+
query = `mutation createReviewMutation($review: ReviewInput!) {
928+
createReview(episode: Empire, review: $review) {
929+
stars
930+
commentary
931+
episode
932+
}
933+
}`;
934+
expect(getQueryTypeComplexity(parse(query), variables, typeWeights)).toBe(11); // Mutation 10 + review 1
935+
});
936+
});
919937

920938
xdescribe('Calculates the correct type complexity for subscriptions', () => {});
921939
});

0 commit comments

Comments
 (0)