Skip to content

Commit 2fae6e7

Browse files
findBreakingChanges: Add new tests to improve coverage (#1899)
1 parent ff0afa2 commit 2fae6e7

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

src/utilities/__tests__/findBreakingChanges-test.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,31 @@ describe('findBreakingChanges', () => {
4848

4949
it('should detect if a type changed its type', () => {
5050
const oldSchema = buildSchema(`
51-
interface Type1
51+
scalar TypeWasScalarBecomesEnum
52+
interface TypeWasInterfaceBecomesUnion
53+
type TypeWasObjectBecomesInputObject
5254
`);
5355

5456
const newSchema = buildSchema(`
55-
union Type1
57+
enum TypeWasScalarBecomesEnum
58+
union TypeWasInterfaceBecomesUnion
59+
input TypeWasObjectBecomesInputObject
5660
`);
5761
expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([
5862
{
5963
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.',
6176
},
6277
]);
6378
});
@@ -566,6 +581,24 @@ describe('findBreakingChanges', () => {
566581
]);
567582
});
568583

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+
569602
it('should detect all breaking changes', () => {
570603
const oldSchema = buildSchema(`
571604
directive @DirectiveThatIsRemoved on FIELD_DEFINITION
@@ -834,20 +867,22 @@ describe('findDangerousChanges', () => {
834867

835868
it('should detect interfaces added to types', () => {
836869
const oldSchema = buildSchema(`
837-
interface Interface1
870+
interface OldInterface
871+
interface NewInterface
838872
839-
type Type1
873+
type Type1 implements OldInterface
840874
`);
841875

842876
const newSchema = buildSchema(`
843-
interface Interface1
877+
interface OldInterface
878+
interface NewInterface
844879
845-
type Type1 implements Interface1
880+
type Type1 implements OldInterface & NewInterface
846881
`);
847882

848883
expect(findDangerousChanges(oldSchema, newSchema)).to.deep.equal([
849884
{
850-
description: 'Interface1 added to interfaces implemented by Type1.',
885+
description: 'NewInterface added to interfaces implemented by Type1.',
851886
type: DangerousChangeType.INTERFACE_ADDED_TO_OBJECT,
852887
},
853888
]);

0 commit comments

Comments
 (0)