Skip to content

Commit 5cf6068

Browse files
committed
fix: clean up birthday command
Clean up tests too PR-URL: #4033 Credit: @wraithgar Close: #4033 Reviewed-by: @lukekarrys
1 parent cd6d3a9 commit 5cf6068

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

lib/commands/birthday.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ const BaseCommand = require('../base-command.js')
22

33
class Birthday extends BaseCommand {
44
async exec () {
5-
this.npm.config.set('package', ['@npmcli/npm-birthday'])
65
this.npm.config.set('yes', true)
7-
const exec = await this.npm.cmd('exec')
8-
return exec.exec(['npm-birthday'])
6+
return this.npm.exec('exec', ['@npmcli/npm-birthday'])
97
}
108
}
119

test/lib/commands/birthday.js

+8-22
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
11
const t = require('tap')
2-
const { fake: mockNpm } = require('../../fixtures/mock-npm')
2+
const { real: mockNpm } = require('../../fixtures/mock-npm')
33

44
t.test('birthday', async t => {
5-
t.plan(4)
6-
const config = {
7-
yes: false,
8-
package: [],
9-
}
10-
const npm = mockNpm({
11-
config,
12-
cmd: async (cmd) => {
13-
t.ok(cmd, 'exec', 'calls out to exec command')
14-
return {
15-
exec: async (args) => {
16-
t.equal(npm.config.get('yes'), true, 'should say yes')
17-
t.strictSame(npm.config.get('package'), ['@npmcli/npm-birthday'],
18-
'uses correct package')
19-
t.strictSame(args, ['npm-birthday'], 'called with correct args')
20-
},
21-
}
5+
t.plan(2)
6+
const { Npm } = mockNpm(t, {
7+
libnpmexec: ({ args, yes }) => {
8+
t.ok(yes)
9+
t.match(args, ['@npmcli/npm-birthday'])
2210
},
2311
})
24-
const Birthday = require('../../../lib/commands/birthday.js')
25-
const birthday = new Birthday(npm)
26-
27-
await birthday.exec([])
12+
const npm = new Npm()
13+
await npm.exec('birthday', [])
2814
})

0 commit comments

Comments
 (0)