add test for getCliLoginById

This commit is contained in:
Nik Graf 2017-09-12 22:36:05 +02:00
parent b75b5c2475
commit 069fcdee6c
No known key found for this signature in database
GPG Key ID: 7A97512F916175F1
3 changed files with 36 additions and 0 deletions

View File

@ -1,3 +1,5 @@
'use strict';
const forge = require('node-forge');
module.exports = (encryptedToken, key, iv) => {

View File

@ -1,3 +1,5 @@
'use strict';
const gql = require('graphql-tag');
module.exports = (id, apolloQueryFn) =>

View File

@ -0,0 +1,32 @@
'use strict';
const sinon = require('sinon');
const expect = require('chai').expect;
const gql = require('graphql-tag');
const getCliLoginById = require('./getCliLoginById');
describe.only('#getCliLoginById()', () => {
it('should query for the cliLoginById', () => {
const expectedParams = {
fetchPolicy: 'network-only',
query: gql`
query cliLoginById($id: String!) {
cliLoginById(id: $id) {
encryptedAccessToken
encryptedIdToken
encryptedRefreshToken
encryptedKey
encryptedIv
}
}
`,
variables: { id: 'abc' },
};
const query = sinon.stub().resolves({ data: { cliLoginId: 'abc' } });
return getCliLoginById('abc', query).then(data => {
expect(data).to.deep.equal({ cliLoginId: 'abc' });
expect(query.getCall(0).args[0]).to.deep.equal(expectedParams);
});
});
});