2017-04-19 14:15:28 -05:00
|
|
|
'use strict';
|
2013-12-07 17:55:50 -05:00
|
|
|
|
2017-04-19 14:15:28 -05:00
|
|
|
let assert = require('assert');
|
|
|
|
let semver_sort = require('../../lib/utils').semver_sort;
|
|
|
|
let merge = require('../../lib/storage')._merge_versions;
|
|
|
|
|
|
|
|
require('../../lib/logger').setup([]);
|
2013-12-07 17:55:50 -05:00
|
|
|
|
2013-12-19 10:11:54 -05:00
|
|
|
describe('Merge', function() {
|
2014-11-12 06:14:37 -05:00
|
|
|
it('simple', function() {
|
2017-04-19 14:15:28 -05:00
|
|
|
let x = {
|
|
|
|
'versions': {a: 1, b: 1, c: 1},
|
2014-11-12 06:14:37 -05:00
|
|
|
'dist-tags': {},
|
2017-04-19 14:15:28 -05:00
|
|
|
};
|
|
|
|
merge(x, {versions: {a: 2, q: 2}});
|
2014-11-12 06:14:37 -05:00
|
|
|
assert.deepEqual(x, {
|
2017-04-19 14:15:28 -05:00
|
|
|
'versions': {a: 1, b: 1, c: 1, q: 2},
|
2014-11-12 06:14:37 -05:00
|
|
|
'dist-tags': {},
|
2017-04-19 14:15:28 -05:00
|
|
|
});
|
|
|
|
});
|
2013-12-07 17:55:50 -05:00
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
it('dist-tags - compat', function() {
|
2017-04-19 14:15:28 -05:00
|
|
|
let x = {
|
|
|
|
'versions': {},
|
|
|
|
'dist-tags': {q: '1.1.1', w: '2.2.2'},
|
|
|
|
};
|
|
|
|
merge(x, {'dist-tags': {q: '2.2.2', w: '3.3.3', t: '4.4.4'}});
|
2014-11-12 06:14:37 -05:00
|
|
|
assert.deepEqual(x, {
|
2017-04-19 14:15:28 -05:00
|
|
|
'versions': {},
|
|
|
|
'dist-tags': {q: '2.2.2', w: '3.3.3', t: '4.4.4'},
|
|
|
|
});
|
|
|
|
});
|
2013-12-07 17:55:50 -05:00
|
|
|
|
2016-10-28 14:25:44 -05:00
|
|
|
it('dist-tags - staging', function() {
|
|
|
|
let x = {
|
|
|
|
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'},
|
|
|
|
}
|
|
|
|
// 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
|
|
|
|
merge(x, {'dist-tags':{q:'1.1.2',w:'3.3.3',t:'4.4.4'}})
|
|
|
|
assert.deepEqual(x, {
|
|
|
|
versions: {},
|
|
|
|
'dist-tags': {q:'1.1.10',w:'3.3.3',t:'4.4.4'},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-11-12 06:14:37 -05:00
|
|
|
it('semver_sort', function() {
|
2017-04-19 14:15:28 -05:00
|
|
|
assert.deepEqual(semver_sort(['1.2.3', '1.2', '1.2.3a', '1.2.3c', '1.2.3-b']),
|
|
|
|
['1.2.3a',
|
2014-11-12 06:14:37 -05:00
|
|
|
'1.2.3-b',
|
|
|
|
'1.2.3c',
|
2017-04-19 14:15:28 -05:00
|
|
|
'1.2.3']
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2013-12-11 15:51:48 -05:00
|
|
|
|