1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/unit/st_merge.js

44 lines
1005 B
JavaScript
Raw Normal View History

2017-04-19 21:15:28 +02:00
'use strict';
2013-12-07 23:55:50 +01:00
2017-04-19 21:15:28 +02: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 23:55:50 +01:00
2013-12-19 16:11:54 +01:00
describe('Merge', function() {
it('simple', function() {
2017-04-19 21:15:28 +02:00
let x = {
'versions': {a: 1, b: 1, c: 1},
'dist-tags': {},
2017-04-19 21:15:28 +02:00
};
merge(x, {versions: {a: 2, q: 2}});
assert.deepEqual(x, {
2017-04-19 21:15:28 +02:00
'versions': {a: 1, b: 1, c: 1, q: 2},
'dist-tags': {},
2017-04-19 21:15:28 +02:00
});
});
2013-12-07 23:55:50 +01:00
it('dist-tags - compat', function() {
2017-04-19 21:15:28 +02: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'}});
assert.deepEqual(x, {
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
it('semver_sort', function() {
2017-04-19 21:15:28 +02:00
assert.deepEqual(semver_sort(['1.2.3', '1.2', '1.2.3a', '1.2.3c', '1.2.3-b']),
['1.2.3a',
'1.2.3-b',
'1.2.3c',
2017-04-19 21:15:28 +02:00
'1.2.3']
);
});
});