Skip to content

Commit 3817cd4

Browse files
committed
update the expected typeWeightsObject in the comlpxity tests to include the function definition for the lists.
1 parent 3510641 commit 3817cd4

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/@types/buildTypeWeights.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
interface Fields {
2-
readonly [index: string]: number;
2+
readonly [index: string]: number | ((arg: number, type: Type) => number);
33
}
44

55
interface Type {

test/analysis/typeComplexityAnalysis.test.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ import getQueryTypeComplexity from '../../src/analysis/typeComplexityAnalysis';
2222
interface Character {
2323
id: ID!
2424
name: String!
25-
friends: [Character]
25+
friends(first: Int): [Character]
2626
appearsIn: [Episode]!
2727
}
2828
2929
type Human implements Character {
3030
id: ID!
3131
name: String!
3232
homePlanet: String
33-
friends: [Character]
33+
friends(first: Int): [Character]
3434
appearsIn: [Episode]!
3535
}
3636
3737
type Droid implements Character {
3838
id: ID!
3939
name: String!
40-
friends: [Character]
40+
friends(first: Int): [Character]
4141
primaryFunction: String
4242
appearsIn: [Episode]!
4343
}
@@ -99,7 +99,11 @@ const typeWeights: TypeWeightObject = {
9999
query: {
100100
// object type
101101
weight: 1,
102-
fields: {},
102+
fields: {
103+
// FIXME: update the function def that is supposed te be here to match implementation
104+
// FIXME: add the function definition for the 'search' field which returns a list
105+
reviews: (arg, type) => arg * type.weight,
106+
},
103107
},
104108
episode: {
105109
// enum
@@ -112,6 +116,7 @@ const typeWeights: TypeWeightObject = {
112116
fields: {
113117
id: 0,
114118
name: 0,
119+
// FIXME: add the function definition for the 'friends' field which returns a list
115120
},
116121
},
117122
human: {
@@ -245,11 +250,9 @@ xdescribe('Test getQueryTypeComplexity function', () => {
245250
xtest('with lists of unknown size', () => {
246251
query = `
247252
Query {
248-
human(id: 1) {
249-
name,
250-
friends {
251-
name
252-
}
253+
search(text: 'hi') {
254+
id
255+
name
253256
}
254257
}`;
255258
expect(getQueryTypeComplexity(query, typeWeights)).toBe(false); // ?

0 commit comments

Comments
 (0)