Created
October 9, 2017 11:17
-
-
Save javierfernandes/bb3973375a703a8dd88c2b560e41193c to your computer and use it in GitHub Desktop.
Sample GraphQL test for a mutation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describeGQL('GRAPHQL API - Objects()', ({ expectQueryResult }) => { | |
| beforeEach('setup objects in mongo', async () => { | |
| await Object.insertMany([ | |
| { project: 'game', id: 10, data: { name: 'Pato Bullrich' } } | |
| ]) | |
| }) | |
| it('objectUpdate() updates an Object', async () => { | |
| await expectQueryResult( | |
| // MUTATION | |
| `mutation updateGame10 { | |
| updateObject(input: { | |
| project: "game", | |
| id: 10, | |
| property: "name", | |
| value: "Donde esta Santiago Maldonado?" | |
| }) { | |
| id | |
| sys | |
| data | |
| } | |
| }`, | |
| // EXPECTED RESPONSE | |
| { | |
| updateGame10: { | |
| project: 'game', | |
| id: 10, | |
| data: { name: 'Donde esta Santiago Maldonado?' } | |
| } | |
| } | |
| ) | |
| // Assert modified in mongo | |
| const updated = await Object.findOne({ project: 'game', id: 10 }) | |
| expect(modifiedBNEObject.data.name).to.equal('Donde esta Santiago Maldonado?') | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment