Skip to content

Commit 5d2568d

Browse files
committed
added notes for additional union test cases
1 parent c5ea420 commit 5d2568d

File tree

1 file changed

+48
-40
lines changed

1 file changed

+48
-40
lines changed

test/analysis/buildTypeWeights.test.ts

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -460,52 +460,60 @@ describe('Test buildTypeWeightsFromSchema function', () => {
460460
});
461461
});
462462

463-
test('union types', () => {
464-
schema = buildSchema(`
465-
union SearchResult = Human | Droid
466-
type Human{
467-
name: String
468-
homePlanet: String
469-
search(first: Int!): [SearchResult]
470-
}
471-
type Droid {
472-
name: String
473-
primaryFunction: String
474-
search(first: Int!): [SearchResult]
475-
}`);
476-
expect(buildTypeWeightsFromSchema(schema)).toEqual({
477-
searchresult: {
478-
weight: 1,
479-
fields: {
480-
name: { weight: 0 },
481-
search: {
482-
resolveTo: 'searchresult',
483-
weight: expect.any(Function),
463+
describe('union types', () => {
464+
test('union types', () => {
465+
schema = buildSchema(`
466+
union SearchResult = Human | Droid
467+
type Human{
468+
name: String
469+
homePlanet: String
470+
search(first: Int!): [SearchResult]
471+
}
472+
type Droid {
473+
name: String
474+
primaryFunction: String
475+
search(first: Int!): [SearchResult]
476+
}`);
477+
expect(buildTypeWeightsFromSchema(schema)).toEqual({
478+
searchresult: {
479+
weight: 1,
480+
fields: {
481+
name: { weight: 0 },
482+
search: {
483+
resolveTo: 'searchresult',
484+
weight: expect.any(Function),
485+
},
484486
},
485487
},
486-
},
487-
human: {
488-
weight: 1,
489-
fields: {
490-
name: { weight: 0 },
491-
homePlanet: { weight: 0 },
492-
search: {
493-
resolveTo: 'searchresult',
494-
weight: expect.any(Function),
488+
human: {
489+
weight: 1,
490+
fields: {
491+
name: { weight: 0 },
492+
homePlanet: { weight: 0 },
493+
search: {
494+
resolveTo: 'searchresult',
495+
weight: expect.any(Function),
496+
},
495497
},
496498
},
497-
},
498-
droid: {
499-
weight: 1,
500-
fields: {
501-
name: { weight: 0 },
502-
primaryFunction: { weight: 0 },
503-
search: {
504-
resolveTo: 'searchresult',
505-
weight: expect.any(Function),
499+
droid: {
500+
weight: 1,
501+
fields: {
502+
name: { weight: 0 },
503+
primaryFunction: { weight: 0 },
504+
search: {
505+
resolveTo: 'searchresult',
506+
weight: expect.any(Function),
507+
},
506508
},
507509
},
508-
},
510+
});
511+
});
512+
513+
xtest('additional test cases for ...', () => {
514+
// TODO: unions with non-null types
515+
// unions with lists of non-null types
516+
// lists with > 2 levels of nesting (may need to add these for lists on other types as well)
509517
});
510518
});
511519

0 commit comments

Comments
 (0)