diff options
Diffstat (limited to 'test/lib/utils/tar.js')
-rw-r--r-- | test/lib/utils/tar.js | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/test/lib/utils/tar.js b/test/lib/utils/tar.js index 19d949169..adc5cb364 100644 --- a/test/lib/utils/tar.js +++ b/test/lib/utils/tar.js @@ -2,18 +2,20 @@ const t = require('tap') const pack = require('libnpmpack') const ssri = require('ssri') -const { logTar, getContents } = require('../../../lib/utils/tar.js') +const { getContents } = require('../../../lib/utils/tar.js') -const printLogs = (tarball, unicode) => { +const mockTar = ({ notice }) => t.mock('../../../lib/utils/tar.js', { + 'proc-log': { + notice, + }, +}) + +const printLogs = (tarball, options) => { const logs = [] - logTar(tarball, { - log: { - notice: (...args) => { - args.map(el => logs.push(el)) - }, - }, - unicode, + const { logTar } = mockTar({ + notice: (...args) => args.map(el => logs.push(el)), }) + logTar(tarball, options) return logs.join('\n') } @@ -41,16 +43,14 @@ t.test('should log tarball contents', async (t) => { version: '1.0.0', }, tarball) - t.matchSnapshot(printLogs(tarballContents, false)) + t.matchSnapshot(printLogs(tarballContents)) }) t.test('should log tarball contents with unicode', async (t) => { - const { logTar } = t.mock('../../../lib/utils/tar.js', { - npmlog: { - notice: (str) => { - t.ok(true, 'defaults to npmlog') - return str - }, + const { logTar } = mockTar({ + notice: (str) => { + t.ok(true, 'defaults to proc-log') + return str }, }) @@ -64,26 +64,6 @@ t.test('should log tarball contents with unicode', async (t) => { t.end() }) -t.test('should default to npmlog', async (t) => { - const { logTar } = t.mock('../../../lib/utils/tar.js', { - npmlog: { - notice: (str) => { - t.ok(true, 'defaults to npmlog') - return str - }, - }, - }) - - logTar({ - files: [], - bundled: [], - size: 0, - unpackedSize: 0, - integrity: '', - }) - t.end() -}) - t.test('should getContents of a tarball', async (t) => { const testDir = t.testdir({ 'package.json': JSON.stringify({ |