Skip to content

Commit d33f49c

Browse files
authored
test: add tests for bot-username module
PR-URL: #189 Reviewed-By: Phillip Johnsen <johphi@gmail.com>
1 parent 67568ed commit d33f49c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/unit/bot-username.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict'
2+
3+
const proxyquire = require('proxyquire')
4+
const sinon = require('sinon')
5+
const tap = require('tap')
6+
7+
const githubClient = require('../../lib/github-client')
8+
9+
tap.test('botUsername.resolve(): returns username of current user', (t) => {
10+
sinon.stub(githubClient.users, 'get').yields(null, { login: 'nodejs-github-bot' })
11+
const botUsername = proxyquire('../../lib/bot-username', {
12+
'./github-client': githubClient
13+
})
14+
15+
t.plan(1)
16+
t.tearDown(() => {
17+
githubClient.users.get.restore()
18+
})
19+
20+
botUsername.resolve((_, username) => {
21+
t.same(username, 'nodejs-github-bot')
22+
})
23+
})

0 commit comments

Comments
 (0)