Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
package: {
version: '1.2.3',
},
}, '1.x', {}), 'range that is satisfied')
t.ok(depValid({
isLink: true,
realpath: '/some/path'
}, npa('file:/some/path'), {}), 'links must point at intended target')
t.notOk(depValid({
isLink: true,
realpath: '/some/other/path'
}, 'file:/some/path', {}), 'links must point at intended target')
t.notOk(depValid({
realpath: '/some/path'
}, 'file:/some/path', {}), 'file:// must be a link')
t.ok(depValid({
name: 'foo',
resolved: 'git://host/repo#somebranch',
package: {
version: '1.2.3',
},
}, 'git://host/repo#semver:1.x', {}), 'git url with semver range')
t.ok(depValid({
name: 'foo',
package: {
name: 'bar',
resolved: '/path/to/tarball.tgz',
}, '/path/to/tarball.tgz', {}), 'same tarball')
t.notOk(depValid({
resolved: '/path/to/other/tarball.tgz',
}, '/path/to/tarball.tgz', {}), 'different tarball')
t.ok(depValid({
resolved: 'https://registry.npmjs.org/foo/foo-1.2.3.tgz',
}, 'latest', {}), 'tagged registry version needs remote tarball')
t.notOk(depValid({
resolved: 'git+https://registry.npmjs.org/foo/foo-1.2.3.git',
}, 'latest', {}), 'tagged registry version needs remote tarball, not git')
t.notOk(depValid({}, 'latest', {}),
'tagged registry version needs remote tarball resolution')
t.test('unsupported dependency type', t => {
const requestor = { errors: [] }
const child = {name: 'kid'}
const request = { type: 'not a type' }
t.notOk(depValid(child, request, requestor))
t.match(requestor, {
errors: [{
message: 'Unsupported dependency type',
dependency: 'kid',
requested: { type: 'not a type' },
}],
}, 'parent got an error for their unsupported request')
t.end()
})
var t = require('tap')
var Parser = require('../')
var p = new Parser()
var called = false
function cb (er) {
if (er)
throw er
called = true
}
p.write('Bail out! this is fine\nok 2 - this is ok\n')
t.notOk(called)
t.ok(p.bailedOut)
p.write('ok 1 - i am ok with how things are proceeding\n', cb)
t.notOk(called)
setTimeout(function () {
t.ok(called)
})
t.test('child calling _parse after bailout', function (t) {
var p = new Parser()
var etoa = require('events-to-array')
var events = etoa(p, [ 'pipe', 'unpipe', 'prefinish', 'finish', 'line' ])
p.on('assert', t.fail)
p.on('complete', function () {
t.matchSnapshot(events, 'events')
t.end()
})
p.end([
package: {},
}, 'git+ssh://git@github.com/bar/foo.git', {}), 'missing repo')
t.ok(depValid({
resolved: '/path/to/tarball.tgz',
}, '/path/to/tarball.tgz', {}), 'same tarball')
t.notOk(depValid({
resolved: '/path/to/other/tarball.tgz',
}, '/path/to/tarball.tgz', {}), 'different tarball')
t.ok(depValid({
resolved: 'https://registry.npmjs.org/foo/foo-1.2.3.tgz',
}, 'latest', {}), 'tagged registry version needs remote tarball')
t.notOk(depValid({
resolved: 'git+https://registry.npmjs.org/foo/foo-1.2.3.git',
}, 'latest', {}), 'tagged registry version needs remote tarball, not git')
t.notOk(depValid({}, 'latest', {}),
'tagged registry version needs remote tarball resolution')
t.test('unsupported dependency type', t => {
const requestor = { errors: [] }
const child = {name: 'kid'}
const request = { type: 'not a type' }
t.notOk(depValid(child, request, requestor))
t.match(requestor, {
errors: [{
message: 'Unsupported dependency type',
dependency: 'kid',
requested: { type: 'not a type' },
tap.equal('foo', 'bar')
tap.not('foo', 'foo')
tap.same({ foo: 1 }, { bar: 1 })
tap.notSame({ foo: 1 }, { foo: 1 })
tap.strictSame([null], [undefined])
tap.strictNotSame([42], [42])
tap.match({ foo: 'bar' }, { foo: /baz/ })
tap.notMatch({ foo: 'bar' }, { foo: /^bar$/ })
tap.type(new Date(), Number)
tap.throws(function () {})
tap.doesNotThrow(function () {
throw new Error('bang!')
})
tap.ok(true)
tap.notOk(false)
tap.error(undefined)
tap.equal('foo', 'foo')
tap.not('foo', 'bar')
tap.same({ foo: 1 }, { foo: 1 })
tap.notSame({ foo: 1 }, { bar: 1 })
tap.strictSame([42], [42])
tap.strictNotSame([null], [undefined])
tap.match({ foo: 'bar' }, { foo: /^bar$/ })
tap.notMatch({ foo: 'bar' }, { foo: /baz/ })
tap.type(new Date(), Date)
tap.throws(function () {
throw new Error('bang!')
})
tap.doesNotThrow(function () {})
name: 'bar',
version: '1.2.3',
},
}, 'npm:bar@1.2.3', {}), 'alias is ok')
t.ok(depValid({
resolved: 'https://registry/abbrev-1.1.1.tgz',
package: {},
}, 'https://registry/abbrev-1.1.1.tgz', {}), 'remote url match')
t.ok(depValid({
resolved: 'git+ssh://git@github.com/foo/bar',
package: {},
}, 'git+ssh://git@github.com/foo/bar.git', {}), 'matching _from saveSpec')
t.notOk(depValid({
resolved: 'git+ssh://git@github.com/foo/bar',
package: {},
}, 'git+ssh://git@github.com/bar/foo.git', {}), 'different repo')
t.notOk(depValid({
package: {},
}, 'git+ssh://git@github.com/bar/foo.git', {}), 'missing repo')
t.ok(depValid({
resolved: '/path/to/tarball.tgz',
}, '/path/to/tarball.tgz', {}), 'same tarball')
t.notOk(depValid({
resolved: '/path/to/other/tarball.tgz',
}, '/path/to/tarball.tgz', {}), 'different tarball')
t.ok(depValid({
resolved: 'https://registry/abbrev-1.1.1.tgz',
package: {},
}, 'https://registry/abbrev-1.1.1.tgz', {}), 'remote url match')
t.ok(depValid({
resolved: 'git+ssh://git@github.com/foo/bar',
package: {},
}, 'git+ssh://git@github.com/foo/bar.git', {}), 'matching _from saveSpec')
t.notOk(depValid({
resolved: 'git+ssh://git@github.com/foo/bar',
package: {},
}, 'git+ssh://git@github.com/bar/foo.git', {}), 'different repo')
t.notOk(depValid({
package: {},
}, 'git+ssh://git@github.com/bar/foo.git', {}), 'missing repo')
t.ok(depValid({
resolved: '/path/to/tarball.tgz',
}, '/path/to/tarball.tgz', {}), 'same tarball')
t.notOk(depValid({
resolved: '/path/to/other/tarball.tgz',
}, '/path/to/tarball.tgz', {}), 'different tarball')
t.ok(depValid({
resolved: 'https://registry.npmjs.org/foo/foo-1.2.3.tgz',
}, 'latest', {}), 'tagged registry version needs remote tarball')
t.notOk(depValid({
t.equal(parsed.SINGLE_QUOTES, 'single_quotes', 'escapes single quoted values')
t.equal(parsed.SINGLE_QUOTES_SPACED, ' single quotes ', 'respects surrounding spaces in single quotes')
t.equal(parsed.DOUBLE_QUOTES, 'double_quotes', 'escapes double quoted values')
t.equal(parsed.DOUBLE_QUOTES_SPACED, ' double quotes ', 'respects surrounding spaces in double quotes')
t.equal(parsed.EXPAND_NEWLINES, 'expand\nnew\nlines', 'expands newlines but only if double quoted')
t.equal(parsed.DONT_EXPAND_UNQUOTED, 'dontexpand\\nnewlines', 'expands newlines but only if double quoted')
t.equal(parsed.DONT_EXPAND_SQUOTED, 'dontexpand\\nnewlines', 'expands newlines but only if double quoted')
t.notOk(parsed.COMMENTS, 'ignores commented lines')
t.equal(parsed.EQUAL_SIGNS, 'equals==', 'respects equals signs in values')
t.equal(parsed.RETAIN_INNER_QUOTES, '{"foo": "bar"}', 'retains inner quotes')
t.equal(parsed.RETAIN_LEADING_DQUOTE, '"retained', 'retains leading double quote')
t.equal(parsed.RETAIN_LEADING_SQUOTE, "'retained", 'retains leading single quote')
t.equal(parsed.RETAIN_TRAILING_DQUOTE, 'retained"', 'reatins trailing double quote')
t.equal(parsed.RETAIN_TRAILING_SQUOTE, "retained'", 'retains trailing single quote')
t.equal(parsed.RETAIN_INNER_QUOTES_AS_STRING, '{"foo": "bar"}', 'retains inner quotes')
t.equal(parsed.TRIM_SPACE_FROM_UNQUOTED, 'some spaced out string', 'retains spaces in string')
args.push(function (err) {
t.notOk(err)
})
fs[method].apply(fs, args)
proNav.forEach(text => {
tap.notOk(res.text.includes(text));
});
test.end();