@@ -48,16 +48,31 @@ describe('findBreakingChanges', () => {
48
48
49
49
it ( 'should detect if a type changed its type' , ( ) => {
50
50
const oldSchema = buildSchema ( `
51
- interface Type1
51
+ scalar TypeWasScalarBecomesEnum
52
+ interface TypeWasInterfaceBecomesUnion
53
+ type TypeWasObjectBecomesInputObject
52
54
` ) ;
53
55
54
56
const newSchema = buildSchema ( `
55
- union Type1
57
+ enum TypeWasScalarBecomesEnum
58
+ union TypeWasInterfaceBecomesUnion
59
+ input TypeWasObjectBecomesInputObject
56
60
` ) ;
57
61
expect ( findBreakingChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
58
62
{
59
63
type : BreakingChangeType . TYPE_CHANGED_KIND ,
60
- description : 'Type1 changed from an Interface type to a Union type.' ,
64
+ description :
65
+ 'TypeWasScalarBecomesEnum changed from a Scalar type to an Enum type.' ,
66
+ } ,
67
+ {
68
+ type : BreakingChangeType . TYPE_CHANGED_KIND ,
69
+ description :
70
+ 'TypeWasInterfaceBecomesUnion changed from an Interface type to a Union type.' ,
71
+ } ,
72
+ {
73
+ type : BreakingChangeType . TYPE_CHANGED_KIND ,
74
+ description :
75
+ 'TypeWasObjectBecomesInputObject changed from an Object type to an Input type.' ,
61
76
} ,
62
77
] ) ;
63
78
} ) ;
@@ -566,6 +581,24 @@ describe('findBreakingChanges', () => {
566
581
] ) ;
567
582
} ) ;
568
583
584
+ it ( 'should ignore changes in order of interfaces' , ( ) => {
585
+ const oldSchema = buildSchema ( `
586
+ interface FirstInterface
587
+ interface SecondInterface
588
+
589
+ type Type1 implements FirstInterface & SecondInterface
590
+ ` ) ;
591
+
592
+ const newSchema = buildSchema ( `
593
+ interface FirstInterface
594
+ interface SecondInterface
595
+
596
+ type Type1 implements SecondInterface & FirstInterface
597
+ ` ) ;
598
+
599
+ expect ( findBreakingChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [ ] ) ;
600
+ } ) ;
601
+
569
602
it ( 'should detect all breaking changes' , ( ) => {
570
603
const oldSchema = buildSchema ( `
571
604
directive @DirectiveThatIsRemoved on FIELD_DEFINITION
@@ -834,20 +867,22 @@ describe('findDangerousChanges', () => {
834
867
835
868
it ( 'should detect interfaces added to types' , ( ) => {
836
869
const oldSchema = buildSchema ( `
837
- interface Interface1
870
+ interface OldInterface
871
+ interface NewInterface
838
872
839
- type Type1
873
+ type Type1 implements OldInterface
840
874
` ) ;
841
875
842
876
const newSchema = buildSchema ( `
843
- interface Interface1
877
+ interface OldInterface
878
+ interface NewInterface
844
879
845
- type Type1 implements Interface1
880
+ type Type1 implements OldInterface & NewInterface
846
881
` ) ;
847
882
848
883
expect ( findDangerousChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
849
884
{
850
- description : 'Interface1 added to interfaces implemented by Type1.' ,
885
+ description : 'NewInterface added to interfaces implemented by Type1.' ,
851
886
type : DangerousChangeType . INTERFACE_ADDED_TO_OBJECT ,
852
887
} ,
853
888
] ) ;
0 commit comments