mirror of
https://github.com/nodejs/node.git
synced 2025-08-18 07:08:50 +02:00

PR-URL: https://github.com/nodejs/node/pull/52767 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
const t = require('tap')
|
|
const mockGlobals = require('@npmcli/mock-globals')
|
|
const tmock = require('../../fixtures/tmock')
|
|
|
|
const mockValidateEngines = (t) => {
|
|
const validateEngines = tmock(t, '{LIB}/cli/validate-engines.js', {
|
|
'{ROOT}/package.json': { version: '1.2.3', engines: { node: '>=0' } },
|
|
})
|
|
mockGlobals(t, { 'process.version': 'v4.5.6' })
|
|
return validateEngines(process, () => (_, r) => r)
|
|
}
|
|
|
|
t.test('validate engines', async t => {
|
|
t.equal(process.listenerCount('uncaughtException'), 0)
|
|
t.equal(process.listenerCount('unhandledRejection'), 0)
|
|
|
|
const result = mockValidateEngines(t)
|
|
|
|
t.equal(process.listenerCount('uncaughtException'), 1)
|
|
t.equal(process.listenerCount('unhandledRejection'), 1)
|
|
|
|
t.match(result, {
|
|
node: 'v4.5.6',
|
|
npm: 'v1.2.3',
|
|
engines: '>=0',
|
|
/* eslint-disable-next-line max-len */
|
|
unsupportedMessage: 'npm v1.2.3 does not support Node.js v4.5.6. This version of npm supports the following node versions: `>=0`. You can find the latest version at https://nodejs.org/.',
|
|
})
|
|
|
|
result.off()
|
|
|
|
t.equal(process.listenerCount('uncaughtException'), 0)
|
|
t.equal(process.listenerCount('unhandledRejection'), 0)
|
|
})
|