@@ -274,4 +274,105 @@ describe('enum', () => {
274274 expect ( change . criticality . reason ) . toBeDefined ( ) ;
275275 expect ( change . message ) . toEqual ( `Enum value 'C' was added to enum 'enumA'` ) ;
276276 } ) ;
277+
278+ describe ( 'string escaping' , ( ) => {
279+ test ( 'deprecation reason changed with escaped single quotes' , async ( ) => {
280+ const a = buildSchema ( /* GraphQL */ `
281+ type Query {
282+ fieldA: String
283+ }
284+
285+ enum enumA {
286+ A @deprecated(reason: "It's old")
287+ B
288+ }
289+ ` ) ;
290+
291+ const b = buildSchema ( /* GraphQL */ `
292+ type Query {
293+ fieldA: String
294+ }
295+
296+ enum enumA {
297+ A @deprecated(reason: "It's new")
298+ B
299+ }
300+ ` ) ;
301+
302+ const changes = await diff ( a , b ) ;
303+ const change = findFirstChangeByPath ( changes , 'enumA.A' ) ;
304+
305+ expect ( changes . length ) . toEqual ( 1 ) ;
306+ expect ( change . criticality . level ) . toEqual ( CriticalityLevel . NonBreaking ) ;
307+ expect ( change . message ) . toEqual (
308+ `Enum value 'enumA.A' deprecation reason changed from 'It\\'s old' to 'It\\'s new'` ,
309+ ) ;
310+ } ) ;
311+
312+ test ( 'deprecation reason added with escaped single quotes' , async ( ) => {
313+ const a = buildSchema ( /* GraphQL */ `
314+ type Query {
315+ fieldA: String
316+ }
317+
318+ enum enumA {
319+ A
320+ B
321+ }
322+ ` ) ;
323+
324+ const b = buildSchema ( /* GraphQL */ `
325+ type Query {
326+ fieldA: String
327+ }
328+
329+ enum enumA {
330+ A @deprecated(reason: "Don't use this")
331+ B
332+ }
333+ ` ) ;
334+
335+ const changes = await diff ( a , b ) ;
336+ const change = findFirstChangeByPath ( changes , 'enumA.A' ) ;
337+
338+ expect ( changes . length ) . toEqual ( 2 ) ;
339+ expect ( change . criticality . level ) . toEqual ( CriticalityLevel . NonBreaking ) ;
340+ expect ( change . message ) . toEqual (
341+ `Enum value 'enumA.A' was deprecated with reason 'Don\\'t use this'` ,
342+ ) ;
343+ } ) ;
344+
345+ test ( 'deprecation reason without single quotes is unchanged' , async ( ) => {
346+ const a = buildSchema ( /* GraphQL */ `
347+ type Query {
348+ fieldA: String
349+ }
350+
351+ enum enumA {
352+ A @deprecated(reason: "Old Reason")
353+ B
354+ }
355+ ` ) ;
356+
357+ const b = buildSchema ( /* GraphQL */ `
358+ type Query {
359+ fieldA: String
360+ }
361+
362+ enum enumA {
363+ A @deprecated(reason: "New Reason")
364+ B
365+ }
366+ ` ) ;
367+
368+ const changes = await diff ( a , b ) ;
369+ const change = findFirstChangeByPath ( changes , 'enumA.A' ) ;
370+
371+ expect ( changes . length ) . toEqual ( 1 ) ;
372+ expect ( change . criticality . level ) . toEqual ( CriticalityLevel . NonBreaking ) ;
373+ expect ( change . message ) . toEqual (
374+ `Enum value 'enumA.A' deprecation reason changed from 'Old Reason' to 'New Reason'` ,
375+ ) ;
376+ } ) ;
377+ } ) ;
277378} ) ;
0 commit comments