Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests by adding missing mocks #116

Merged
merged 2 commits into from
Nov 17, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added mocks for new Slack API requests
  • Loading branch information
limulus committed Nov 1, 2015
commit 8a734fcdab341d28abda062fad44122c5683c079
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"devDependencies": {
"mocha": "2.2.4",
"nock": "0.48.1",
"nock": "^2.17.0",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please remove the ^. I want to maintain reproducible/deterministic builds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, sorry that slipped in there! This is now fixed.

"supertest": "0.15.0"
},
"engines": {
Expand Down
34 changes: 22 additions & 12 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@ import slackin from '../lib/index';

describe('slackin', () => {
describe('POST /invite', () => {
let mockNumUsers = (org) => {
nock(`https://${org}.slack.com`)
.get('/api/rtm.start?token=mytoken')
beforeEach(() => {
nock('https://myorg.slack.com')
.get('/api/users.list')
.query({token: 'mytoken', presence: '1'})
.query({token: 'mytoken'})
.reply(200, {
channels: [{}],
team: {
name: 'myteam',
icon: {}
},
users: [{}]
ok: true,
members: [{}]
});
};

nock('https://myorg.slack.com')
.get('/api/channels.list?token=mytoken')
.reply(200, {
ok: true,
channels: [{}]
});

nock('https://myorg.slack.com')
.get('/api/team.info?token=mytoken')
.reply(200, {
ok: true,
team: {icon: {}}
})
});

it("returns success for a successful invite", (done) => {
let opts = {
Expand All @@ -24,7 +36,6 @@ describe('slackin', () => {
};

// TODO simplify mocking
mockNumUsers(opts.org);
nock(`https://${opts.org}.slack.com`)
.post('/api/users.admin.invite')
.reply(200, { ok: true });
Expand All @@ -46,7 +57,6 @@ describe('slackin', () => {
};

// TODO simplify mocking
mockNumUsers(opts.org);
nock(`https://${opts.org}.slack.com`)
.post('/api/users.admin.invite')
.reply(200, {
Expand Down