-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathstarWarsMutation-test.ts
47 lines (44 loc) · 1.03 KB
/
starWarsMutation-test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { graphqlSync } from 'graphql';
import { StarWarsSchema as schema } from './starWarsSchema';
describe('Star Wars mutations', () => {
it('mutates the data set', () => {
const source = `
mutation ($input: IntroduceShipInput!) {
introduceShip(input: $input) {
ship {
id
name
}
faction {
name
}
clientMutationId
}
}
`;
const variableValues = {
input: {
shipName: 'B-Wing',
factionId: '1',
clientMutationId: 'abcde',
},
};
const result = graphqlSync({ schema, source, variableValues });
expect(result).to.deep.equal({
data: {
introduceShip: {
ship: {
id: 'U2hpcDo5',
name: 'B-Wing',
},
faction: {
name: 'Alliance to Restore the Republic',
},
clientMutationId: 'abcde',
},
},
});
});
});