2017-04-19 21:15:28 +02:00
|
|
|
let assert = require('assert');
|
2018-02-24 20:19:06 +01:00
|
|
|
let semverSort = require('../../src/lib/utils').semverSort;
|
2017-12-22 21:32:52 +01:00
|
|
|
import Storage from '../../src/lib/storage';
|
2017-04-19 21:15:28 +02:00
|
|
|
|
2017-06-21 19:02:52 +02:00
|
|
|
require('../../src/lib/logger').setup([]);
|
2013-12-07 23:55:50 +01:00
|
|
|
|
2017-12-22 21:32:52 +01:00
|
|
|
describe('Storage._merge_versions versions', () => {
|
2017-08-05 10:34:31 +02:00
|
|
|
|
2017-11-01 17:47:20 +01:00
|
|
|
test('simple', () => {
|
2017-08-05 10:34:31 +02:00
|
|
|
let pkg = {
|
2017-04-19 21:15:28 +02:00
|
|
|
'versions': {a: 1, b: 1, c: 1},
|
2014-11-12 12:14:37 +01:00
|
|
|
'dist-tags': {},
|
2017-04-19 21:15:28 +02:00
|
|
|
};
|
2017-08-05 10:34:31 +02:00
|
|
|
|
2018-02-03 22:36:28 +01:00
|
|
|
Storage._mergeVersions(pkg, {versions: {a: 2, q: 2}});
|
2017-08-05 10:34:31 +02:00
|
|
|
|
|
|
|
assert.deepEqual(pkg, {
|
2017-04-19 21:15:28 +02:00
|
|
|
'versions': {a: 1, b: 1, c: 1, q: 2},
|
2014-11-12 12:14:37 +01:00
|
|
|
'dist-tags': {},
|
2017-04-19 21:15:28 +02:00
|
|
|
});
|
|
|
|
});
|
2013-12-07 23:55:50 +01:00
|
|
|
|
2017-11-01 17:47:20 +01:00
|
|
|
test('dist-tags - compat', () => {
|
2017-08-05 10:34:31 +02:00
|
|
|
let pkg = {
|
2017-04-19 21:15:28 +02:00
|
|
|
'versions': {},
|
|
|
|
'dist-tags': {q: '1.1.1', w: '2.2.2'},
|
|
|
|
};
|
2017-08-05 10:34:31 +02:00
|
|
|
|
2018-02-03 22:36:28 +01:00
|
|
|
Storage._mergeVersions(pkg, {'dist-tags': {q: '2.2.2', w: '3.3.3', t: '4.4.4'}});
|
2017-08-05 10:34:31 +02:00
|
|
|
|
|
|
|
assert.deepEqual(pkg, {
|
2017-04-19 21:15:28 +02:00
|
|
|
'versions': {},
|
|
|
|
'dist-tags': {q: '2.2.2', w: '3.3.3', t: '4.4.4'},
|
|
|
|
});
|
|
|
|
});
|
2013-12-07 23:55:50 +01:00
|
|
|
|
2017-11-01 17:47:20 +01:00
|
|
|
test('dist-tags - staging', () => {
|
2017-08-05 10:34:31 +02:00
|
|
|
|
|
|
|
let pkg = {
|
2016-10-28 21:25:44 +02:00
|
|
|
versions: {},
|
|
|
|
// we've been locally publishing 1.1.x in preparation for the next
|
|
|
|
// public release
|
|
|
|
'dist-tags': {q:'1.1.10',w:'2.2.2'},
|
2017-08-05 10:34:31 +02:00
|
|
|
};
|
2016-10-28 21:25:44 +02:00
|
|
|
// 1.1.2 is the latest public release, but we want to continue testing
|
|
|
|
// against our local 1.1.10, which may end up published as 1.1.3 in the
|
|
|
|
// future
|
2017-08-05 10:34:31 +02:00
|
|
|
|
2018-02-03 22:36:28 +01:00
|
|
|
Storage._mergeVersions(pkg, {'dist-tags':{q:'1.1.2',w:'3.3.3',t:'4.4.4'}})
|
2017-08-05 10:34:31 +02:00
|
|
|
|
|
|
|
assert.deepEqual(pkg, {
|
2016-10-28 21:25:44 +02:00
|
|
|
versions: {},
|
|
|
|
'dist-tags': {q:'1.1.10',w:'3.3.3',t:'4.4.4'},
|
|
|
|
});
|
2017-08-05 10:34:31 +02:00
|
|
|
|
2016-10-28 21:25:44 +02:00
|
|
|
});
|
|
|
|
|
2018-02-24 20:19:06 +01:00
|
|
|
test('semverSort', () => {
|
2017-08-05 10:34:31 +02:00
|
|
|
|
2018-02-24 20:19:06 +01:00
|
|
|
assert.deepEqual(semverSort(['1.2.3', '1.2', '1.2.3a', '1.2.3c', '1.2.3-b']),
|
2017-04-19 21:15:28 +02:00
|
|
|
['1.2.3a',
|
2014-11-12 12:14:37 +01:00
|
|
|
'1.2.3-b',
|
|
|
|
'1.2.3c',
|
2017-04-19 21:15:28 +02:00
|
|
|
'1.2.3']
|
|
|
|
);
|
2017-08-05 10:34:31 +02:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
});
|
2017-08-05 10:34:31 +02:00
|
|
|
|
2017-04-19 21:15:28 +02:00
|
|
|
});
|
2013-12-11 21:51:48 +01:00
|
|
|
|