diff --git a/lib/commands/birthday.js b/lib/commands/birthday.js index 4fa0268f8bcfa..5dd9331d836c8 100644 --- a/lib/commands/birthday.js +++ b/lib/commands/birthday.js @@ -2,10 +2,8 @@ const BaseCommand = require('../base-command.js') class Birthday extends BaseCommand { async exec () { - this.npm.config.set('package', ['@npmcli/npm-birthday']) this.npm.config.set('yes', true) - const exec = await this.npm.cmd('exec') - return exec.exec(['npm-birthday']) + return this.npm.exec('exec', ['@npmcli/npm-birthday']) } } diff --git a/test/lib/commands/birthday.js b/test/lib/commands/birthday.js index c92f197c5f3f1..8c95dd57b2e3a 100644 --- a/test/lib/commands/birthday.js +++ b/test/lib/commands/birthday.js @@ -1,28 +1,14 @@ const t = require('tap') -const { fake: mockNpm } = require('../../fixtures/mock-npm') +const { real: mockNpm } = require('../../fixtures/mock-npm') t.test('birthday', async t => { - t.plan(4) - const config = { - yes: false, - package: [], - } - const npm = mockNpm({ - config, - cmd: async (cmd) => { - t.ok(cmd, 'exec', 'calls out to exec command') - return { - exec: async (args) => { - t.equal(npm.config.get('yes'), true, 'should say yes') - t.strictSame(npm.config.get('package'), ['@npmcli/npm-birthday'], - 'uses correct package') - t.strictSame(args, ['npm-birthday'], 'called with correct args') - }, - } + t.plan(2) + const { Npm } = mockNpm(t, { + libnpmexec: ({ args, yes }) => { + t.ok(yes) + t.match(args, ['@npmcli/npm-birthday']) }, }) - const Birthday = require('../../../lib/commands/birthday.js') - const birthday = new Birthday(npm) - - await birthday.exec([]) + const npm = new Npm() + await npm.exec('birthday', []) })