Created
December 30, 2018 20:18
-
-
Save JeffML/ebd9f8067ea1c7c2dd161c1968ab2dee to your computer and use it in GitHub Desktop.
This file contains 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
/* 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