Ghost/test/unit/lib/ghost-version_spec.js
Hannah Wolfe 7f1d3ebc07
Move tests from core to root (#11700)
- move all test files from core/test to test/
- updated all imports and other references
- all code inside of core/ is then application code
- tests are correctly at the root level
- consistent with other repos/projects

Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
2020-03-30 16:26:47 +01:00

72 lines
2.1 KiB
JavaScript

const should = require('should');
const rewire = require('rewire');
const mockUtils = require('../../utils/mocks');
let ghostVersionUtils, version;
describe('Utils: Ghost Version', function () {
const beforeEachIt = function be() {
mockUtils.modules.mockNonExistentModule(/package\.json/, {version: version});
ghostVersionUtils = rewire('../../../core/server/lib/ghost-version');
};
afterEach(function () {
mockUtils.modules.unmockNonExistentModule(/package\.json/);
});
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');
});
});