Skip to content

Commit 987ea27

Browse files
committed
minor fix for testing directives violation
1 parent 9c0b13a commit 987ea27

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

graphql-server/test/directives-tests.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,34 +253,37 @@ describe('# directives tests', () => {
253253
let mutation = `mutation {
254254
deleteTargetEdgeFromRequiredForTargetTest(id: "${edgeId2}") { id }
255255
}`;
256-
await request(url, mutation)
257-
.then(() => {
258-
throw new Error(`@requiredForTarget directive should yield an error since no requiredForTarget edge will exist`);
259-
})
256+
let result = await request(url, mutation)
257+
.then(() => new Error(`@requiredForTarget directive should yield an error since no requiredForTarget edge will exist`))
260258
.catch(() => null);
259+
if(result){
260+
throw result;
261+
}
261262
});
262263

263264
it('delete source of edge connecting to target', async () => {
264265
// No more fields connecting to targetId1, mutation should fail
265266
let mutation = `mutation {
266267
deleteRequiredForTargetTest(id: "${id2}") { id }
267268
}`;
268-
await request(url, mutation)
269-
.then(() => {
270-
throw new Error(`@requiredForTarget directive should yield an error since the source of edge (and edge) will cease to exist`);
271-
})
272-
.catch(() => null);
269+
let result = await request(url, mutation)
270+
.then(() => new Error(`@requiredForTarget directive should yield an error since the source of edge (and edge) will cease to exist`))
271+
.catch((err) => null);
272+
if(result){
273+
throw result;
274+
}
273275
});
274276

275277
it('create only target', async () => {
276278
let mutation = `mutation {
277279
createRequiredForTargetTarget(data:{ }) { id }
278280
}`;
279-
await request(url, mutation)
280-
.then(() => {
281-
throw new Error(`@requiredForTarget directive should yield an error when attempting to create objects out of order`);
282-
})
281+
let result = await request(url, mutation)
282+
.then(() => new Error(`@requiredForTarget directive should yield an error when attempting to create objects out of order`))
283283
.catch(() => null);
284+
if(result){
285+
throw result;
286+
}
284287
});
285288

286289
it('create object and target using dependent mutations', async () => {

0 commit comments

Comments
 (0)