Skip to content

Instantly share code, notes, and snippets.

@javierfernandes
Created October 9, 2017 11:23
Show Gist options
  • Select an option

  • Save javierfernandes/543ce163c93afa9a3e42cb658cef8c6c to your computer and use it in GitHub Desktop.

Select an option

Save javierfernandes/543ce163c93afa9a3e42cb658cef8c6c to your computer and use it in GitHub Desktop.
it('objectUpdated receives an update from calling mutation updateObject() in the same project', async () => {
// SUBSCRIBE and make a promise
const subscriptionPromise = new Promise((resolve, reject) => {
client().subscribe({
query: gql`
subscription objectUpdated {
objectUpdated(project: "game") {
id
property
value
}
}`
}).subscribe({
next: resolve,
error: reject
})
})
// MUTATE
await execGraphQL(
`mutation updateBNEObject {
updateObject(input: { project: "game", id: 10, property: "name", value: "Donde esta Santiago Maldonado?"}) {
id
}
}`
)
// ASSERT SUBSCRIPTION RECEIVED EVENT
expect(await subscriptionPromise).to.deep.equal({
objectUpdated: {
__typename: 'ObjectPropertyChanged',
id: 10,
property: 'name',
value: 'Donde esta Santiago Maldonado?'
}
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment