Skip to content

Instantly share code, notes, and snippets.

@JeffML
Created December 30, 2018 20:18
Show Gist options
  • Save JeffML/ebd9f8067ea1c7c2dd161c1968ab2dee to your computer and use it in GitHub Desktop.
Save JeffML/ebd9f8067ea1c7c2dd161c1968ab2dee to your computer and use it in GitHub Desktop.
/* eslint-env mocha */
import chai from 'chai';
import fetch, { subscribe } from './fetch';
chai.should();
describe('subscribe, then go', function () {
this.timeout(5000);
const handlers = {
next: (data) => {
console.log(`received data:`, data);
if (data.data.info === 'done') {
console.log('exiting...')
process.exit(0);
}
},
error: error => console.error(`received error ${error}`),
};
// get the subscriber ready...
it('subscribe', async () => {
const query = `subscription {
info
}`;
subscribe(query, handlers);
});
it('go', async () => {
const query = `query {
go
}`;
const res = (await fetch(query)).data;
res.should.have.property('go')
res.go.should.equal('going')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment