Skip to content

Instantly share code, notes, and snippets.

@somahargitai
Last active March 29, 2018 08:56
Show Gist options
  • Save somahargitai/85781c67f805ff9bb515ae0c71df7b6e to your computer and use it in GitHub Desktop.
Save somahargitai/85781c67f805ff9bb515ae0c71df7b6e to your computer and use it in GitHub Desktop.
import sinon from 'sinon';
import expect from 'chai';
import factory from '../../../factory';
import * as resolvers from '../../../graphql/resolvers';
import * as service from '../../../services/service';
describe('resolvers', async () => {
let sandbox;
beforeEach(() => {
sandbox = sinon.sandbox.create();
});
afterEach(() => {
sandbox.restore();
});
test.serial('should ensure that it gets called with the correct parameters', async () => {
const args = {
historical: true,
first: 25,
after: undefined,
};
const someStuff = await factory.create('someStuff');
context.someStuff = someStuff;
const stub = sinon.stub(service, 'serviceFunction');
resolvers.resolverFunction(stub, undefined, args, context);
expect(service.serviceFunction.getCall(0).args).to.deep.equal([true, 25, undefined]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment