@@ -22,6 +22,23 @@ describe('findSchemaChanges', () => {
2222 ] ) ;
2323 } ) ;
2424
25+ it ( 'should detect a type changing description' , ( ) => {
26+ const newSchema = buildSchema ( `
27+ "New Description"
28+ type Type1
29+ ` ) ;
30+
31+ const oldSchema = buildSchema ( `
32+ type Type1
33+ ` ) ;
34+ expect ( findSchemaChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
35+ {
36+ type : SafeChangeType . DESCRIPTION_CHANGED ,
37+ description : 'Description of Type1 has changed to "New Description".' ,
38+ } ,
39+ ] ) ;
40+ } ) ;
41+
2542 it ( 'should detect if a field was added' , ( ) => {
2643 const oldSchema = buildSchema ( `
2744 type Query {
@@ -43,6 +60,30 @@ describe('findSchemaChanges', () => {
4360 ] ) ;
4461 } ) ;
4562
63+ it ( 'should detect a field changing description' , ( ) => {
64+ const oldSchema = buildSchema ( `
65+ type Query {
66+ foo: String
67+ bar: String
68+ }
69+ ` ) ;
70+
71+ const newSchema = buildSchema ( `
72+ type Query {
73+ foo: String
74+ "New Description"
75+ bar: String
76+ }
77+ ` ) ;
78+ expect ( findSchemaChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
79+ {
80+ type : SafeChangeType . DESCRIPTION_CHANGED ,
81+ description :
82+ 'Description of field Query.bar has changed to "New Description".' ,
83+ } ,
84+ ] ) ;
85+ } ) ;
86+
4687 it ( 'should detect if a default value was added' , ( ) => {
4788 const oldSchema = buildSchema ( `
4889 type Query {
@@ -84,6 +125,30 @@ describe('findSchemaChanges', () => {
84125 ] ) ;
85126 } ) ;
86127
128+ it ( 'should detect if an arg value changes description' , ( ) => {
129+ const oldSchema = buildSchema ( `
130+ type Query {
131+ foo(x: String!): String
132+ }
133+ ` ) ;
134+
135+ const newSchema = buildSchema ( `
136+ type Query {
137+ foo(
138+ "New Description"
139+ x: String!
140+ ): String
141+ }
142+ ` ) ;
143+ expect ( findSchemaChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
144+ {
145+ type : SafeChangeType . DESCRIPTION_CHANGED ,
146+ description :
147+ 'Description of argument Query.foo(x) has changed to "New Description".' ,
148+ } ,
149+ ] ) ;
150+ } ) ;
151+
87152 it ( 'should detect if a directive was added' , ( ) => {
88153 const oldSchema = buildSchema ( `
89154 type Query {
@@ -106,6 +171,31 @@ describe('findSchemaChanges', () => {
106171 ] ) ;
107172 } ) ;
108173
174+ it ( 'should detect if a directive changes description' , ( ) => {
175+ const oldSchema = buildSchema ( `
176+ directive @Foo on FIELD_DEFINITION
177+
178+ type Query {
179+ foo: String
180+ }
181+ ` ) ;
182+
183+ const newSchema = buildSchema ( `
184+ "New Description"
185+ directive @Foo on FIELD_DEFINITION
186+
187+ type Query {
188+ foo: String
189+ }
190+ ` ) ;
191+ expect ( findSchemaChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
192+ {
193+ description : 'Description of @Foo has changed to "New Description".' ,
194+ type : SafeChangeType . DESCRIPTION_CHANGED ,
195+ } ,
196+ ] ) ;
197+ } ) ;
198+
109199 it ( 'should detect if a directive becomes repeatable' , ( ) => {
110200 const oldSchema = buildSchema ( `
111201 directive @Foo on FIELD_DEFINITION
@@ -177,4 +267,94 @@ describe('findSchemaChanges', () => {
177267 } ,
178268 ] ) ;
179269 } ) ;
270+
271+ it ( 'should detect if a directive arg changes description' , ( ) => {
272+ const oldSchema = buildSchema ( `
273+ directive @Foo(
274+ arg1: String
275+ ) on FIELD_DEFINITION
276+
277+ type Query {
278+ foo: String
279+ }
280+ ` ) ;
281+
282+ const newSchema = buildSchema ( `
283+ directive @Foo(
284+ "New Description"
285+ arg1: String
286+ ) on FIELD_DEFINITION
287+
288+ type Query {
289+ foo: String
290+ }
291+ ` ) ;
292+ expect ( findSchemaChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
293+ {
294+ description :
295+ 'Description of @Foo(Foo) has changed to "New Description".' ,
296+ type : SafeChangeType . DESCRIPTION_CHANGED ,
297+ } ,
298+ ] ) ;
299+ } ) ;
300+
301+ it ( 'should detect if an enum member changes description' , ( ) => {
302+ const oldSchema = buildSchema ( `
303+ enum Foo {
304+ TEST
305+ }
306+
307+ type Query {
308+ foo: String
309+ }
310+ ` ) ;
311+
312+ const newSchema = buildSchema ( `
313+ enum Foo {
314+ "New Description"
315+ TEST
316+ }
317+
318+ type Query {
319+ foo: String
320+ }
321+ ` ) ;
322+ expect ( findSchemaChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
323+ {
324+ description :
325+ 'Description of enum value Foo.TEST has changed to "New Description".' ,
326+ type : SafeChangeType . DESCRIPTION_CHANGED ,
327+ } ,
328+ ] ) ;
329+ } ) ;
330+
331+ it ( 'should detect if an input field changes description' , ( ) => {
332+ const oldSchema = buildSchema ( `
333+ input Foo {
334+ x: String
335+ }
336+
337+ type Query {
338+ foo: String
339+ }
340+ ` ) ;
341+
342+ const newSchema = buildSchema ( `
343+ input Foo {
344+ "New Description"
345+ x: String
346+ }
347+
348+ type Query {
349+ foo: String
350+ }
351+ ` ) ;
352+ expect ( findSchemaChanges ( oldSchema , newSchema ) ) . to . deep . equal ( [
353+ {
354+ description :
355+ 'Description of input-field Foo.x has changed to "New Description".' ,
356+ type : SafeChangeType . DESCRIPTION_CHANGED ,
357+ } ,
358+ ] ) ;
359+ } ) ;
180360} ) ;
0 commit comments