@@ -274,4 +274,195 @@ describe('enum', () => {
274274 expect ( change . criticality . reason ) . toBeDefined ( ) ;
275275 expect ( change . message ) . toEqual ( `Enum value 'C' was added to enum 'enumA'` ) ;
276276 } ) ;
277- } ) ;
277+
278+ describe ( 'useDoubleQuotes option' , ( ) => {
279+ test ( 'value added with double quotes' , async ( ) => {
280+ const a = buildSchema ( /* GraphQL */ `
281+ type Query {
282+ fieldA: String
283+ }
284+
285+ enum enumA {
286+ A
287+ B
288+ }
289+ ` ) ;
290+
291+ const b = buildSchema ( /* GraphQL */ `
292+ type Query {
293+ fieldA: String
294+ }
295+
296+ enum enumA {
297+ A
298+ B
299+ C
300+ }
301+ ` ) ;
302+
303+ const changes = await diff ( a , b , [ ] , { useDoubleQuotes : true } ) ;
304+ const change = findFirstChangeByPath ( changes , 'enumA.C' ) ;
305+
306+ expect ( changes . length ) . toEqual ( 1 ) ;
307+ expect ( change . criticality . level ) . toEqual ( CriticalityLevel . Dangerous ) ;
308+ expect ( change . message ) . toEqual ( `Enum value "C" was added to enum "enumA"` ) ;
309+ } ) ;
310+
311+ test ( 'value removed with double quotes' , async ( ) => {
312+ const a = buildSchema ( /* GraphQL */ `
313+ type Query {
314+ fieldA: String
315+ }
316+
317+ enum enumA {
318+ A
319+ B
320+ }
321+ ` ) ;
322+
323+ const b = buildSchema ( /* GraphQL */ `
324+ type Query {
325+ fieldA: String
326+ }
327+
328+ enum enumA {
329+ A
330+ }
331+ ` ) ;
332+
333+ const changes = await diff ( a , b , [ ] , { useDoubleQuotes : true } ) ;
334+ const change = findFirstChangeByPath ( changes , 'enumA.B' ) ;
335+
336+ expect ( changes . length ) . toEqual ( 1 ) ;
337+ expect ( change . criticality . level ) . toEqual ( CriticalityLevel . Breaking ) ;
338+ expect ( change . message ) . toEqual ( `Enum value "B" was removed from enum "enumA"` ) ;
339+ } ) ;
340+
341+ test ( 'deprecation reason changed with double quotes' , async ( ) => {
342+ const a = buildSchema ( /* GraphQL */ `
343+ type Query {
344+ fieldA: String
345+ }
346+
347+ enum enumA {
348+ A @deprecated(reason: "Old Reason")
349+ B
350+ }
351+ ` ) ;
352+
353+ const b = buildSchema ( /* GraphQL */ `
354+ type Query {
355+ fieldA: String
356+ }
357+
358+ enum enumA {
359+ A @deprecated(reason: "New Reason")
360+ B
361+ }
362+ ` ) ;
363+
364+ const changes = await diff ( a , b , [ ] , { useDoubleQuotes : true } ) ;
365+ const change = findFirstChangeByPath ( changes , 'enumA.A' ) ;
366+
367+ expect ( changes . length ) . toEqual ( 1 ) ;
368+ expect ( change . criticality . level ) . toEqual ( CriticalityLevel . NonBreaking ) ;
369+ expect ( change . message ) . toEqual (
370+ `Enum value "enumA.A" deprecation reason changed from "Old Reason" to "New Reason"` ,
371+ ) ;
372+ } ) ;
373+
374+ test ( 'deprecation reason added with double quotes' , async ( ) => {
375+ const a = buildSchema ( /* GraphQL */ `
376+ type Query {
377+ fieldA: String
378+ }
379+
380+ enum enumA {
381+ A
382+ B
383+ }
384+ ` ) ;
385+
386+ const b = buildSchema ( /* GraphQL */ `
387+ type Query {
388+ fieldA: String
389+ }
390+
391+ enum enumA {
392+ A @deprecated(reason: "New Reason")
393+ B
394+ }
395+ ` ) ;
396+
397+ const changes = await diff ( a , b , [ ] , { useDoubleQuotes : true } ) ;
398+ const change = findFirstChangeByPath ( changes , 'enumA.A' ) ;
399+
400+ expect ( changes . length ) . toEqual ( 2 ) ;
401+ expect ( change . criticality . level ) . toEqual ( CriticalityLevel . NonBreaking ) ;
402+ expect ( change . message ) . toEqual (
403+ `Enum value "enumA.A" was deprecated with reason "New Reason"` ,
404+ ) ;
405+ } ) ;
406+
407+ test ( 'deprecation reason removed with double quotes' , async ( ) => {
408+ const a = buildSchema ( /* GraphQL */ `
409+ type Query {
410+ fieldA: String
411+ }
412+
413+ enum enumA {
414+ A @deprecated(reason: "New Reason")
415+ B
416+ }
417+ ` ) ;
418+
419+ const b = buildSchema ( /* GraphQL */ `
420+ type Query {
421+ fieldA: String
422+ }
423+
424+ enum enumA {
425+ A
426+ B
427+ }
428+ ` ) ;
429+
430+ const changes = await diff ( a , b , [ ] , { useDoubleQuotes : true } ) ;
431+ const change = findFirstChangeByPath ( changes , 'enumA.A' ) ;
432+
433+ expect ( changes . length ) . toEqual ( 2 ) ;
434+ expect ( change . criticality . level ) . toEqual ( CriticalityLevel . NonBreaking ) ;
435+ expect ( change . message ) . toEqual ( `Deprecation reason was removed from enum value "enumA.A"` ) ;
436+ } ) ;
437+
438+ test ( 'removal of a deprecated field with double quotes' , async ( ) => {
439+ const a = buildSchema ( /* GraphQL */ `
440+ type Query {
441+ fieldA: String
442+ }
443+
444+ enum enumA {
445+ A @deprecated(reason: "New Reason")
446+ B
447+ }
448+ ` ) ;
449+
450+ const b = buildSchema ( /* GraphQL */ `
451+ type Query {
452+ fieldA: String
453+ }
454+
455+ enum enumA {
456+ B
457+ }
458+ ` ) ;
459+
460+ const changes = await diff ( a , b , [ ] , { useDoubleQuotes : true } ) ;
461+ const change = findFirstChangeByPath ( changes , 'enumA.A' ) ;
462+
463+ expect ( changes . length ) . toEqual ( 1 ) ;
464+ expect ( change . criticality . level ) . toEqual ( CriticalityLevel . Breaking ) ;
465+ expect ( change . message ) . toEqual ( `Enum value "A" (deprecated) was removed from enum "enumA"` ) ;
466+ } ) ;
467+ } ) ;
468+ } ) ;
0 commit comments