Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2015-07-08 08:46:45 +0300
committerRebecca Turner <me@re-becca.org>2015-07-10 01:38:48 +0300
commite8352954ac0d34bd34b0886aa264f549282fc5e5 (patch)
tree3c9625f35a1567589c29ef66836b3f99b4feb738 /test
parent6151c6225cff02efffe585c8ca5d1c03d3c9d285 (diff)
cache: Make "*" match "latest" if all versions are prerelease
Fixes: #8855 PR-URL: https://github.com/npm/npm/pull/8857
Diffstat (limited to 'test')
-rw-r--r--test/tap/splat-with-only-prerelease-to-latest.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/test/tap/splat-with-only-prerelease-to-latest.js b/test/tap/splat-with-only-prerelease-to-latest.js
new file mode 100644
index 000000000..d402bed29
--- /dev/null
+++ b/test/tap/splat-with-only-prerelease-to-latest.js
@@ -0,0 +1,81 @@
+'use strict'
+var test = require('tap').test
+var npm = require('../../lib/npm')
+var log = require('npmlog')
+var stream = require('readable-stream')
+
+var moduleName = 'xyzzy-wibble'
+var testModule = {
+ name: moduleName,
+ 'dist-tags': {
+ latest: '1.3.0-a'
+ },
+ versions: {
+ '1.0.0-a': {
+ name: moduleName,
+ version: '1.0.0-a',
+ dist: {
+ shasum: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ tarball: 'http://registry.npmjs.org/aproba/-/xyzzy-wibble-1.0.0-a.tgz'
+ }
+ },
+ '1.1.0-a': {
+ name: moduleName,
+ version: '1.1.0-a',
+ dist: {
+ shasum: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ tarball: 'http://registry.npmjs.org/aproba/-/xyzzy-wibble-1.1.0-a.tgz'
+ }
+ },
+ '1.2.0-a': {
+ name: moduleName,
+ version: '1.2.0-a',
+ dist: {
+ shasum: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ tarball: 'http://registry.npmjs.org/aproba/-/xyzzy-wibble-1.2.0-a.tgz'
+ }
+ },
+ '1.3.0-a': {
+ name: moduleName,
+ version: '1.3.0-a',
+ dist: {
+ shasum: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ tarball: 'http://registry.npmjs.org/aproba/-/xyzzy-wibble-1.3.0-a.tgz'
+ }
+ },
+ },
+}
+
+var lastFetched
+test('setup', function (t) {
+ npm.load(function(){
+ npm.config.set('loglevel', 'silly')
+ npm.registry = {
+ get: function (uri, opts, cb) {
+ setImmediate(function () {
+ cb(null, testModule, null, {statusCode: 200})
+ })
+ },
+ fetch: function (u, opts, cb) {
+ lastFetched = u
+ setImmediate(function () {
+ var empty = new stream.Readable()
+ empty.push(null)
+ cb(null, empty)
+ })
+ }
+ }
+ t.end()
+ })
+})
+
+
+test('splat', function (t) {
+ t.plan(3)
+ var addNamed = require('../../lib/cache/add-named.js')
+ addNamed('xyzzy-wibble', '*', testModule, function (err, pkg) {
+ t.error(err, 'Succesfully resolved a splat package')
+ t.is(pkg.name, moduleName)
+ t.is(pkg.version, testModule['dist-tags'].latest)
+ })
+})