2020-03-25 14:19:16 +03:00
|
|
|
const should = require('should');
|
|
|
|
const rewire = require('rewire');
|
|
|
|
const mockUtils = require('../../utils/mocks');
|
2018-01-03 22:20:18 +03:00
|
|
|
|
2020-04-29 18:44:27 +03:00
|
|
|
let ghostVersionUtils;
|
|
|
|
let version;
|
2018-01-03 22:20:18 +03:00
|
|
|
|
|
|
|
describe('Utils: Ghost Version', function () {
|
|
|
|
const beforeEachIt = function be() {
|
2020-03-25 14:19:16 +03:00
|
|
|
mockUtils.modules.mockNonExistentModule(/package\.json/, {version: version});
|
2018-01-03 22:20:18 +03:00
|
|
|
|
2020-03-30 18:26:47 +03:00
|
|
|
ghostVersionUtils = rewire('../../../core/server/lib/ghost-version');
|
2018-01-03 22:20:18 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(function () {
|
2020-03-25 14:19:16 +03:00
|
|
|
mockUtils.modules.unmockNonExistentModule(/package\.json/);
|
2018-01-03 22:20:18 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('default', function () {
|
|
|
|
version = '1.10.0';
|
|
|
|
beforeEachIt();
|
|
|
|
|
|
|
|
ghostVersionUtils.full.should.eql(version);
|
|
|
|
ghostVersionUtils.original.should.eql(version);
|
|
|
|
ghostVersionUtils.safe.should.eql('1.10');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('pre-release', function () {
|
|
|
|
version = '1.11.1-beta';
|
|
|
|
beforeEachIt();
|
|
|
|
|
|
|
|
ghostVersionUtils.full.should.eql(version);
|
|
|
|
ghostVersionUtils.original.should.eql(version);
|
|
|
|
ghostVersionUtils.safe.should.eql('1.11');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('pre-release .1', function () {
|
|
|
|
version = '1.11.1-alpha.1';
|
|
|
|
beforeEachIt();
|
|
|
|
|
|
|
|
ghostVersionUtils.full.should.eql(version);
|
|
|
|
ghostVersionUtils.original.should.eql(version);
|
|
|
|
ghostVersionUtils.safe.should.eql('1.11');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('build', function () {
|
|
|
|
version = '1.11.1+build';
|
|
|
|
beforeEachIt();
|
|
|
|
|
|
|
|
ghostVersionUtils.full.should.eql('1.11.1');
|
|
|
|
ghostVersionUtils.original.should.eql(version);
|
|
|
|
ghostVersionUtils.safe.should.eql('1.11');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('mixed', function () {
|
|
|
|
version = '1.11.1-pre+build.1';
|
|
|
|
beforeEachIt();
|
|
|
|
|
|
|
|
ghostVersionUtils.full.should.eql('1.11.1-pre');
|
|
|
|
ghostVersionUtils.original.should.eql(version);
|
|
|
|
ghostVersionUtils.safe.should.eql('1.11');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('mixed 1', function () {
|
|
|
|
version = '1.11.1-beta.12+build.2';
|
|
|
|
beforeEachIt();
|
|
|
|
|
|
|
|
ghostVersionUtils.full.should.eql('1.11.1-beta.12');
|
|
|
|
ghostVersionUtils.original.should.eql(version);
|
|
|
|
ghostVersionUtils.safe.should.eql('1.11');
|
|
|
|
});
|
|
|
|
});
|