Skip to content

Commit

Permalink
update test and sinon version
Browse files Browse the repository at this point in the history
  • Loading branch information
radTuti committed Jun 6, 2017
1 parent adc7f3a commit d840e0e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.0",
"nyc": "^10.1.2",
"sinon": "^1.17.7",
"sinon": "^2.1.0",
"tap-spec": "^4.1.1",
"tape": "^4.6.3",
"tape-catch": "^1.0.6"
Expand Down
19 changes: 19 additions & 0 deletions test/client/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ test('Client.constructor - with proxy', (expect) => {
expect.end();
});

test('Client.sendMessage - with tag', (expect) => {
expect.plan(1);
sinon.stub(fetch, 'Promise')
.returns(Promise.resolve(testResponse.generic));
const testClient = new Client('PAGE_ACCESS_TOKEN');
testClient.sendMessage(new TextMessage('hello, world!').withTag('ISSUE_RESOLUTION'), 'USER_ID')
.then(resp => expect.same(resp, testResponse.generic.json(), 'should return test response'));
tearDown();
});

test('Client.sendMessage - error', (expect) => {
expect.plan(1);
Expand All @@ -93,6 +102,16 @@ test('Client.getUserProfile', (expect) => {
tearDown();
});

test('Client.getUserProfile - error', (expect) => {
expect.plan(1);
sinon.stub(fetch, 'Promise').rejects(testResponse.errorCode);
const testClient = new Client('PAGE_ACCESS_TOKEN');
testClient.getUserProfile('USER_ID')
.catch(e => expect.same(e, new Error(testResponse.errorCode.json()
.error.name), 'should return test response'));
tearDown();
});

test('Client.markSeen', (expect) => {
expect.plan(1);
sinon.stub(fetch, 'Promise')
Expand Down

0 comments on commit d840e0e

Please sign in to comment.