11cb0ef41Sopenharmony_ciconst t = require('tap') 21cb0ef41Sopenharmony_ciconst mockGlobals = require('@npmcli/mock-globals') 31cb0ef41Sopenharmony_ciconst tmock = require('../../fixtures/tmock') 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst mockValidateEngines = (t) => { 61cb0ef41Sopenharmony_ci const validateEngines = tmock(t, '{LIB}/es6/validate-engines.js', { 71cb0ef41Sopenharmony_ci '{ROOT}/package.json': { version: '1.2.3', engines: { node: '>=0' } }, 81cb0ef41Sopenharmony_ci }) 91cb0ef41Sopenharmony_ci mockGlobals(t, { 'process.version': 'v4.5.6' }) 101cb0ef41Sopenharmony_ci return validateEngines(process, () => (_, r) => r) 111cb0ef41Sopenharmony_ci} 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cit.test('validate engines', async t => { 141cb0ef41Sopenharmony_ci t.equal(process.listenerCount('uncaughtException'), 0) 151cb0ef41Sopenharmony_ci t.equal(process.listenerCount('unhandledRejection'), 0) 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci const result = mockValidateEngines(t) 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci t.equal(process.listenerCount('uncaughtException'), 1) 201cb0ef41Sopenharmony_ci t.equal(process.listenerCount('unhandledRejection'), 1) 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci t.match(result, { 231cb0ef41Sopenharmony_ci node: 'v4.5.6', 241cb0ef41Sopenharmony_ci npm: 'v1.2.3', 251cb0ef41Sopenharmony_ci engines: '>=0', 261cb0ef41Sopenharmony_ci /* eslint-disable-next-line max-len */ 271cb0ef41Sopenharmony_ci 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/.', 281cb0ef41Sopenharmony_ci }) 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci result.off() 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci t.equal(process.listenerCount('uncaughtException'), 0) 331cb0ef41Sopenharmony_ci t.equal(process.listenerCount('unhandledRejection'), 0) 341cb0ef41Sopenharmony_ci}) 35