Skip to content

Commit ec020fb

Browse files
findBreakingChanges-test: Remove unnecessary fields (#1897)
1 parent ab93bf4 commit ec020fb

File tree

1 file changed

+51
-146
lines changed

1 file changed

+51
-146
lines changed

src/utilities/__tests__/findBreakingChanges-test.js

Lines changed: 51 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,12 @@ import {
3030
describe('findBreakingChanges', () => {
3131
it('should detect if a type was removed or not', () => {
3232
const oldSchema = buildSchema(`
33-
type Type1 {
34-
field1: String
35-
}
36-
37-
type Type2 {
38-
field1: String
39-
}
33+
type Type1
34+
type Type2
4035
`);
4136

4237
const newSchema = buildSchema(`
43-
type Type2 {
44-
field1: String
45-
}
38+
type Type2
4639
`);
4740
expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([
4841
{
@@ -55,17 +48,11 @@ describe('findBreakingChanges', () => {
5548

5649
it('should detect if a type changed its type', () => {
5750
const oldSchema = buildSchema(`
58-
interface Type1 {
59-
field1: String
60-
}
51+
interface Type1
6152
`);
6253

6354
const newSchema = buildSchema(`
64-
type ObjectType {
65-
field1: String
66-
}
67-
68-
union Type1 = ObjectType
55+
union Type1
6956
`);
7057
expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([
7158
{
@@ -77,9 +64,8 @@ describe('findBreakingChanges', () => {
7764

7865
it('should detect if a field on a type was deleted or changed type', () => {
7966
const oldSchema = buildSchema(`
80-
type TypeA {
81-
field1: String
82-
}
67+
type TypeA
68+
type TypeB
8369
8470
interface Type1 {
8571
field1: TypeA
@@ -103,13 +89,8 @@ describe('findBreakingChanges', () => {
10389
`);
10490

10591
const newSchema = buildSchema(`
106-
type TypeA {
107-
field1: String
108-
}
109-
110-
type TypeB {
111-
field1: String
112-
}
92+
type TypeA
93+
type TypeB
11394
11495
interface Type1 {
11596
field1: TypeA
@@ -305,32 +286,16 @@ describe('findBreakingChanges', () => {
305286

306287
it('should detect if a type was removed from a union type', () => {
307288
const oldSchema = buildSchema(`
308-
type Type1 {
309-
field1: String
310-
}
311-
312-
type Type2 {
313-
field1: String
314-
}
315-
316-
type Type3 {
317-
field1: String
318-
}
289+
type Type1
290+
type Type2
291+
type Type3
319292
320293
union UnionType1 = Type1 | Type2
321294
`);
322295
const newSchema = buildSchema(`
323-
type Type1 {
324-
field1: String
325-
}
326-
327-
type Type2 {
328-
field1: String
329-
}
330-
331-
type Type3 {
332-
field1: String
333-
}
296+
type Type1
297+
type Type2
298+
type Type3
334299
335300
union UnionType1 = Type1 | Type3
336301
`);
@@ -582,23 +547,15 @@ describe('findBreakingChanges', () => {
582547

583548
it('should detect interfaces removed from types', () => {
584549
const oldSchema = buildSchema(`
585-
interface Interface1 {
586-
field1: String
587-
}
550+
interface Interface1
588551
589-
type Type1 implements Interface1 {
590-
field1: String
591-
}
552+
type Type1 implements Interface1
592553
`);
593554

594555
const newSchema = buildSchema(`
595-
interface Interface1 {
596-
field1: String
597-
}
556+
interface Interface1
598557
599-
type Type1 {
600-
field1: String
601-
}
558+
type Type1
602559
`);
603560

604561
expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([
@@ -629,31 +586,16 @@ describe('findBreakingChanges', () => {
629586
VALUE2
630587
}
631588
632-
interface Interface1 {
633-
field1: String
634-
}
635-
636-
type TypeThatGainsInterface1 implements Interface1 {
637-
field1: String
638-
}
639-
640-
type TypeInUnion1 {
641-
field1: String
642-
}
643-
644-
type TypeInUnion2 {
645-
field1: String
646-
}
589+
interface Interface1
590+
type TypeThatLooseInterface1 implements Interface1
647591
592+
type TypeInUnion1
593+
type TypeInUnion2
648594
union UnionTypeThatLosesAType = TypeInUnion1 | TypeInUnion2
649595
650-
type TypeThatChangesType {
651-
field1: String
652-
}
596+
type TypeThatChangesType
653597
654-
type TypeThatGetsRemoved {
655-
field1: String
656-
}
598+
type TypeThatGetsRemoved
657599
658600
interface TypeThatHasBreakingFieldChanges {
659601
field1: String
@@ -677,23 +619,14 @@ describe('findBreakingChanges', () => {
677619
VALUE2
678620
}
679621
680-
interface Interface1 {
681-
field1: String
682-
}
683-
684-
type TypeInUnion1 {
685-
field1: String
686-
}
622+
interface Interface1
623+
type TypeThatLooseInterface1
687624
625+
type TypeInUnion1
626+
type TypeInUnion2
688627
union UnionTypeThatLosesAType = TypeInUnion1
689628
690-
interface TypeThatChangesType {
691-
field1: String
692-
}
693-
694-
type TypeThatGainsInterface1 {
695-
field1: String
696-
}
629+
interface TypeThatChangesType
697630
698631
interface TypeThatHasBreakingFieldChanges {
699632
field2: Boolean
@@ -705,10 +638,6 @@ describe('findBreakingChanges', () => {
705638
type: BreakingChangeType.TYPE_REMOVED,
706639
description: 'Int was removed.',
707640
},
708-
{
709-
type: BreakingChangeType.TYPE_REMOVED,
710-
description: 'TypeInUnion2 was removed.',
711-
},
712641
{
713642
type: BreakingChangeType.TYPE_REMOVED,
714643
description: 'TypeThatGetsRemoved was removed.',
@@ -745,7 +674,7 @@ describe('findBreakingChanges', () => {
745674
{
746675
type: BreakingChangeType.INTERFACE_REMOVED_FROM_OBJECT,
747676
description:
748-
'TypeThatGainsInterface1 no longer implements interface Interface1.',
677+
'TypeThatLooseInterface1 no longer implements interface Interface1.',
749678
},
750679
{
751680
type: BreakingChangeType.DIRECTIVE_REMOVED,
@@ -905,19 +834,15 @@ describe('findDangerousChanges', () => {
905834

906835
it('should detect interfaces added to types', () => {
907836
const oldSchema = buildSchema(`
908-
type Type1 {
909-
field1: String
910-
}
837+
interface Interface1
838+
839+
type Type1
911840
`);
912841

913842
const newSchema = buildSchema(`
914-
interface Interface1 {
915-
field1: String
916-
}
843+
interface Interface1
917844
918-
type Type1 implements Interface1 {
919-
field1: String
920-
}
845+
type Type1 implements Interface1
921846
`);
922847

923848
expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([
@@ -930,21 +855,15 @@ describe('findDangerousChanges', () => {
930855

931856
it('should detect if a type was added to a union type', () => {
932857
const oldSchema = buildSchema(`
933-
type Type1 {
934-
field1: String
935-
}
858+
type Type1
859+
type Type2
936860
937861
union UnionType1 = Type1
938862
`);
939863

940864
const newSchema = buildSchema(`
941-
type Type1 {
942-
field1: String
943-
}
944-
945-
type Type2 {
946-
field1: String
947-
}
865+
type Type1
866+
type Type2
948867
949868
union UnionType1 = Type1 | Type2
950869
`);
@@ -988,17 +907,13 @@ describe('findDangerousChanges', () => {
988907
}
989908
990909
type Type1 {
991-
field1(name: String = "test"): String
910+
field1(argThatChangesDefaultValue: String = "test"): String
992911
}
993912
994-
type TypeThatGainsInterface1 {
995-
field1: String
996-
}
997-
998-
type TypeInUnion1 {
999-
field1: String
1000-
}
913+
interface Interface1
914+
type TypeThatGainsInterface1
1001915
916+
type TypeInUnion1
1002917
union UnionTypeThatGainsAType = TypeInUnion1
1003918
`);
1004919

@@ -1009,32 +924,22 @@ describe('findDangerousChanges', () => {
1009924
VALUE2
1010925
}
1011926
1012-
interface Interface1 {
1013-
field1: String
1014-
}
1015-
1016-
type TypeThatGainsInterface1 implements Interface1 {
1017-
field1: String
1018-
}
1019-
1020927
type Type1 {
1021-
field1(name: String = "Test"): String
928+
field1(argThatChangesDefaultValue: String = "Test"): String
1022929
}
1023930
1024-
type TypeInUnion1 {
1025-
field1: String
1026-
}
1027-
1028-
type TypeInUnion2 {
1029-
field1: String
1030-
}
931+
interface Interface1
932+
type TypeThatGainsInterface1 implements Interface1
1031933
934+
type TypeInUnion1
935+
type TypeInUnion2
1032936
union UnionTypeThatGainsAType = TypeInUnion1 | TypeInUnion2
1033937
`);
1034938

1035939
expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([
1036940
{
1037-
description: 'Type1.field1 arg name has changed defaultValue',
941+
description:
942+
'Type1.field1 arg argThatChangesDefaultValue has changed defaultValue',
1038943
type: 'ARG_DEFAULT_VALUE_CHANGE',
1039944
},
1040945
{

0 commit comments

Comments
 (0)