0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/test/unit/lib/ghost-version_spec.js
Katharina Irrgang 341f719d92
Extended ghost version utility (#9278)
refs https://github.com/TryGhost/Ghost-Release/issues/24

- differentiate between
  1. original package.json version (can contain pre and build suffix)
  2. full package.json version X.X.X-{pre} (optional)
  3. safe package.json version X.X (major+minor)
2018-01-03 20:20:18 +01:00

75 lines
2.1 KiB
JavaScript

'use strict';
// jshint unused: false
const should = require('should'),
rewire = require('rewire'),
testUtils = require('../../utils');
let ghostVersionUtils,
version;
describe('Utils: Ghost Version', function () {
const beforeEachIt = function be() {
testUtils.mockNotExistingModule(/package\.json/, {version: version});
ghostVersionUtils = rewire('../../../server/lib/ghost-version');
};
afterEach(function () {
testUtils.unmockNotExistingModule(/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');
});
});