diff options
author | Ruy Adorno <ruyadorno@hotmail.com> | 2019-10-04 17:23:50 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2019-10-08 02:29:15 +0300 |
commit | f3299acd0b4249500e940776aca77cc6c0977263 (patch) | |
tree | aa4931c7202f938abca3863ceaa01d8946677452 /test | |
parent | 3547d99892a3da43831ad74b47488750d4f2da36 (diff) |
Reimplemented using idealTree param
PR-URL: https://github.com/npm/cli/pull/257
Credit: @ruyadorno
Close: #257
Reviewed-by: @isaacs
Diffstat (limited to 'test')
-rw-r--r-- | test/tap/check-engine-reqs.js | 6 | ||||
-rw-r--r-- | test/tap/validate-tree-check-warnings.js | 44 |
2 files changed, 3 insertions, 47 deletions
diff --git a/test/tap/check-engine-reqs.js b/test/tap/check-engine-reqs.js index 7ebb29484..fa25e28dd 100644 --- a/test/tap/check-engine-reqs.js +++ b/test/tap/check-engine-reqs.js @@ -47,9 +47,9 @@ test('warns on bad engine not strict', function (t) { t.ifError(err, 'npm ran without issue') t.is(code, 0, 'result code') var result = JSON.parse(stdout) - t.match(result.warnings[1], /Unsupported engine/, 'reason for optional failure in JSON') - t.match(result.warnings[1], /1.0.0-not-a-real-version/, 'should print mismatch version info') - t.match(result.warnings[1], /Not compatible with your version of node/, 'incompatibility message') + t.match(result.warnings[0], /Unsupported engine/, 'reason for optional failure in JSON') + t.match(result.warnings[0], /1.0.0-not-a-real-version/, 'should print mismatch version info') + t.match(result.warnings[0], /Not compatible with your version of node/, 'incompatibility message') t.done() }) }) diff --git a/test/tap/validate-tree-check-warnings.js b/test/tap/validate-tree-check-warnings.js deleted file mode 100644 index 7b0bd4535..000000000 --- a/test/tap/validate-tree-check-warnings.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict' -var test = require('tap').test -var log = require('npmlog') -var npm = require('../../lib/npm.js') -var checkEngine = require('npm-install-checks').checkEngine - -var idealTree = { - package: { - name: 'a b c', - version: '3.what' - }, - children: [{ - name: 'faulty-engine', - version: '0.0.1', - children: [], - engines: { - node: '>=2.0.0' - }, - package: { - name: 'faulty-engine', - version: '0.0.1' - } - }], - warnings: [] -} - -test('setup', function (t) { - const faultyEnginePkg = idealTree.children[0] - checkEngine(faultyEnginePkg, '1.0.0', '1.0.0', false, false, (err, warn) => { - t.ifError(err, 'check engine ran without issue') - faultyEnginePkg.package.warnings = [warn] - npm.load({}, t.end) - }) -}) - -test('validate-tree should collect warnings from modules', function (t) { - log.disableProgress() - var validateTree = require('../../lib/install/validate-tree.js') - validateTree(idealTree, log.newGroup('validate'), function (er, a, b) { - t.equal(idealTree.warnings[0].code, 'ENOTSUP', 'should have the correct error') - t.match(idealTree.warnings[0].message, /Unsupported engine/, 'reason for optional failure in JSON') - t.end() - }) -}) |