@@ -50,6 +50,37 @@ describe('findDescriptionChanges', () => {
50
50
expect ( findDescriptionChanges ( newSchema , newSchema ) ) . to . eql ( [ ] ) ;
51
51
} ) ;
52
52
53
+ it ( 'should detect if a description was changed on a type' , ( ) => {
54
+ const typeOld = new GraphQLObjectType ( {
55
+ name : 'Type' ,
56
+ description : 'Something rather' ,
57
+ fields : {
58
+ field1 : { type : GraphQLString } ,
59
+ } ,
60
+ } ) ;
61
+ const typeNew = new GraphQLObjectType ( {
62
+ name : 'Type' ,
63
+ description : 'Something else' ,
64
+ fields : {
65
+ field1 : { type : GraphQLString } ,
66
+ } ,
67
+ } ) ;
68
+
69
+ const oldSchema = new GraphQLSchema ( {
70
+ query : queryType ,
71
+ types : [ typeOld ] ,
72
+ } ) ;
73
+ const newSchema = new GraphQLSchema ( {
74
+ query : queryType ,
75
+ types : [ typeNew ] ,
76
+ } ) ;
77
+ expect ( findDescriptionChanges ( oldSchema , newSchema ) [ 0 ] . description ) . to . eql (
78
+ 'Description changed on TYPE Type.' ,
79
+ ) ;
80
+ expect ( findDescriptionChanges ( oldSchema , oldSchema ) ) . to . eql ( [ ] ) ;
81
+ expect ( findDescriptionChanges ( newSchema , newSchema ) ) . to . eql ( [ ] ) ;
82
+ } ) ;
83
+
53
84
it ( 'should detect if a type with a description was added' , ( ) => {
54
85
const type = new GraphQLObjectType ( {
55
86
name : 'Type' ,
@@ -73,4 +104,37 @@ describe('findDescriptionChanges', () => {
73
104
expect ( findDescriptionChanges ( oldSchema , oldSchema ) ) . to . eql ( [ ] ) ;
74
105
expect ( findDescriptionChanges ( newSchema , newSchema ) ) . to . eql ( [ ] ) ;
75
106
} ) ;
107
+
108
+ it ( 'should detect if a field with a description was added' , ( ) => {
109
+ const typeOld = new GraphQLObjectType ( {
110
+ name : 'Type' ,
111
+ fields : {
112
+ field1 : { type : GraphQLString } ,
113
+ } ,
114
+ } ) ;
115
+ const typeNew = new GraphQLObjectType ( {
116
+ name : 'Type' ,
117
+ fields : {
118
+ field1 : { type : GraphQLString } ,
119
+ field2 : {
120
+ type : GraphQLString ,
121
+ description : 'Something rather' ,
122
+ } ,
123
+ } ,
124
+ } ) ;
125
+
126
+ const oldSchema = new GraphQLSchema ( {
127
+ query : queryType ,
128
+ types : [ typeOld ] ,
129
+ } ) ;
130
+ const newSchema = new GraphQLSchema ( {
131
+ query : queryType ,
132
+ types : [ typeNew ] ,
133
+ } ) ;
134
+ expect ( findDescriptionChanges ( oldSchema , newSchema ) [ 0 ] . description ) . to . eql (
135
+ 'New FIELD field2 added with description.' ,
136
+ ) ;
137
+ expect ( findDescriptionChanges ( oldSchema , oldSchema ) ) . to . eql ( [ ] ) ;
138
+ expect ( findDescriptionChanges ( newSchema , newSchema ) ) . to . eql ( [ ] ) ;
139
+ } ) ;
76
140
} ) ;
0 commit comments