@@ -3,7 +3,7 @@ import { plugin } from "../plugin";
3
3
4
4
describe ( "plugin" , ( ) => {
5
5
it ( "should create factories with built-in types" , async ( ) => {
6
- const schema = buildSchema ( `
6
+ const schema = buildSchema ( /* GraphQL */ `
7
7
type User {
8
8
id: ID!
9
9
organizationId: ID
@@ -45,7 +45,7 @@ describe("plugin", () => {
45
45
} ) ;
46
46
47
47
it ( "should use enums as types" , async ( ) => {
48
- const schema = buildSchema ( `
48
+ const schema = buildSchema ( /* GraphQL */ `
49
49
type User {
50
50
status: UserStatus!
51
51
}
@@ -61,7 +61,7 @@ describe("plugin", () => {
61
61
} ) ;
62
62
63
63
it ( "should use the custom scalar defaults" , async ( ) => {
64
- const schema = buildSchema ( `
64
+ const schema = buildSchema ( /* GraphQL */ `
65
65
type User {
66
66
createdAt: Date!
67
67
}
@@ -76,7 +76,7 @@ describe("plugin", () => {
76
76
} ) ;
77
77
78
78
it ( "should create factories for inputs" , async ( ) => {
79
- const schema = buildSchema ( `
79
+ const schema = buildSchema ( /* GraphQL */ `
80
80
input PostInput {
81
81
id: ID
82
82
title: String!
@@ -88,7 +88,7 @@ describe("plugin", () => {
88
88
} ) ;
89
89
90
90
it ( "should create factories for Query and Mutation" , async ( ) => {
91
- const schema = buildSchema ( `
91
+ const schema = buildSchema ( /* GraphQL */ `
92
92
type User {
93
93
id: ID!
94
94
}
@@ -107,7 +107,7 @@ describe("plugin", () => {
107
107
} ) ;
108
108
109
109
it ( "should customize the factory name" , async ( ) => {
110
- const schema = buildSchema ( `
110
+ const schema = buildSchema ( /* GraphQL */ `
111
111
type User {
112
112
id: ID!
113
113
}
@@ -118,7 +118,7 @@ describe("plugin", () => {
118
118
} ) ;
119
119
120
120
it ( "should customize the maybe value default" , async ( ) => {
121
- const schema = buildSchema ( `
121
+ const schema = buildSchema ( /* GraphQL */ `
122
122
type Post {
123
123
title: String
124
124
}
@@ -134,7 +134,7 @@ describe("plugin", () => {
134
134
} ) ;
135
135
136
136
it ( "should customize the maybe value default and input maybe value default independently" , async ( ) => {
137
- const schema = buildSchema ( `
137
+ const schema = buildSchema ( /* GraphQL */ `
138
138
type Post {
139
139
title: String
140
140
}
@@ -151,7 +151,7 @@ describe("plugin", () => {
151
151
} ) ;
152
152
153
153
it ( "should customize the input maybe value default" , async ( ) => {
154
- const schema = buildSchema ( `
154
+ const schema = buildSchema ( /* GraphQL */ `
155
155
input PostInput {
156
156
title: String
157
157
}
@@ -164,7 +164,7 @@ describe("plugin", () => {
164
164
} ) ;
165
165
166
166
it ( "should support enums with an underscore" , async ( ) => {
167
- const schema = buildSchema ( `
167
+ const schema = buildSchema ( /* GraphQL */ `
168
168
enum UserRole {
169
169
SUPER_ADMIN
170
170
ADMIN
@@ -179,7 +179,7 @@ describe("plugin", () => {
179
179
} ) ;
180
180
181
181
it ( "should support directives" , async ( ) => {
182
- const schema = buildSchema ( `
182
+ const schema = buildSchema ( /* GraphQL */ `
183
183
directive @test on FIELD_DEFINITION
184
184
185
185
type User {
@@ -192,7 +192,7 @@ describe("plugin", () => {
192
192
} ) ;
193
193
194
194
it ( "should import types from other file" , async ( ) => {
195
- const schema = buildSchema ( `
195
+ const schema = buildSchema ( /* GraphQL */ `
196
196
type User {
197
197
id: ID!
198
198
}
@@ -206,7 +206,7 @@ describe("plugin", () => {
206
206
} ) ;
207
207
208
208
it ( "should create factories for unions" , async ( ) => {
209
- const schema = buildSchema ( `
209
+ const schema = buildSchema ( /* GraphQL */ `
210
210
type User {
211
211
firstName: String!
212
212
lastName: String!
@@ -237,4 +237,48 @@ describe("plugin", () => {
237
237
const output = await plugin ( schema , [ ] , { } ) ;
238
238
expect ( output ) . toMatchSnapshot ( ) ;
239
239
} ) ;
240
+
241
+ it ( "should add descriptions" , async ( ) => {
242
+ const schema = buildSchema ( /* GraphQL */ `
243
+ """
244
+ This is a description with /* characters that need to be escaped */.
245
+ """
246
+ type Post {
247
+ title: String
248
+ }
249
+
250
+ """
251
+ This is a description for an input.
252
+ """
253
+ input PostInput {
254
+ title: String
255
+ }
256
+ ` ) ;
257
+
258
+ const output = await plugin ( schema , [ ] , { } ) ;
259
+ expect ( output ) . toMatchSnapshot ( ) ;
260
+ } ) ;
261
+
262
+ it ( "should disable descriptions" , async ( ) => {
263
+ const schema = buildSchema ( /* GraphQL */ `
264
+ """
265
+ This is a description with /* characters that need to be escaped */.
266
+ """
267
+ type Post {
268
+ title: String
269
+ }
270
+
271
+ """
272
+ This is a description for an input.
273
+ """
274
+ input PostInput {
275
+ title: String
276
+ }
277
+ ` ) ;
278
+
279
+ const output = await plugin ( schema , [ ] , {
280
+ disableDescriptions : true ,
281
+ } ) ;
282
+ expect ( output ) . toMatchSnapshot ( ) ;
283
+ } ) ;
240
284
} ) ;
0 commit comments