mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Rewritten labs unit test to use assert
over should
refs https://github.com/TryGhost/DevOps/issues/72 - assert is the way we're going with assertion libraries and makes the code a little clearer
This commit is contained in:
parent
500507ff21
commit
1432c6f311
1 changed files with 21 additions and 22 deletions
|
@ -1,4 +1,4 @@
|
|||
const should = require('should');
|
||||
const assert = require('assert/strict');
|
||||
const sinon = require('sinon');
|
||||
|
||||
const configUtils = require('../../utils/configUtils');
|
||||
|
@ -22,7 +22,7 @@ describe('Labs Service', function () {
|
|||
});
|
||||
|
||||
it('can getAll, even if empty with enabled members', function () {
|
||||
labs.getAll().should.eql(expectedLabsObject({
|
||||
assert.deepEqual(labs.getAll(), expectedLabsObject({
|
||||
members: true
|
||||
}));
|
||||
});
|
||||
|
@ -32,18 +32,18 @@ describe('Labs Service', function () {
|
|||
sinon.stub(process.env, 'NODE_ENV').value('production');
|
||||
sinon.stub(settingsCache, 'get');
|
||||
settingsCache.get.withArgs('labs').returns({
|
||||
oauthLogin: true
|
||||
urlCache: true
|
||||
});
|
||||
|
||||
// NOTE: this test should be rewritten to test the alpha flag independently of the internal ALPHA_FEATURES list
|
||||
// otherwise we end up in the endless maintenance loop and need to update it every time a feature graduates from alpha
|
||||
labs.getAll().should.eql(expectedLabsObject({
|
||||
oauthLogin: true,
|
||||
assert.deepEqual(labs.getAll(), expectedLabsObject({
|
||||
urlCache: true,
|
||||
members: true
|
||||
}));
|
||||
|
||||
labs.isSet('members').should.be.true;
|
||||
labs.isSet('oauthLogin').should.be.true;
|
||||
assert.equal(labs.isSet('members'), true);
|
||||
assert.equal(labs.isSet('urlCache'), true);
|
||||
});
|
||||
|
||||
it('returns a falsy alpha flag when dev experiments in NOT toggled', function () {
|
||||
|
@ -51,29 +51,28 @@ describe('Labs Service', function () {
|
|||
sinon.stub(process.env, 'NODE_ENV').value('production');
|
||||
sinon.stub(settingsCache, 'get');
|
||||
settingsCache.get.withArgs('labs').returns({
|
||||
oauthLogin: true
|
||||
urlCache: true
|
||||
});
|
||||
|
||||
// NOTE: this test should be rewritten to test the alpha flag independently of the internal ALPHA_FEATURES list
|
||||
// otherwise we end up in the endless maintenance loop and need to update it every time a feature graduates from alpha
|
||||
labs.getAll().should.eql(expectedLabsObject({
|
||||
oauthLogin: true,
|
||||
assert.deepEqual(labs.getAll(), expectedLabsObject({
|
||||
members: true
|
||||
}));
|
||||
|
||||
labs.isSet('members').should.be.true;
|
||||
labs.isSet('oauthLogin').should.be.false;
|
||||
assert.equal(labs.isSet('members'), true);
|
||||
assert.equal(labs.isSet('urlCache'), false);
|
||||
});
|
||||
|
||||
it('members flag is true when members_signup_access setting is "all"', function () {
|
||||
sinon.stub(settingsCache, 'get');
|
||||
settingsCache.get.withArgs('members_signup_access').returns('all');
|
||||
|
||||
labs.getAll().should.eql(expectedLabsObject({
|
||||
assert.deepEqual(labs.getAll(), expectedLabsObject({
|
||||
members: true
|
||||
}));
|
||||
|
||||
labs.isSet('members').should.be.true;
|
||||
assert.equal(labs.isSet('members'), true);
|
||||
});
|
||||
|
||||
it('returns other allowlisted flags along with members', function () {
|
||||
|
@ -83,32 +82,32 @@ describe('Labs Service', function () {
|
|||
activitypub: false
|
||||
});
|
||||
|
||||
labs.getAll().should.eql(expectedLabsObject({
|
||||
assert.deepEqual(labs.getAll(), expectedLabsObject({
|
||||
members: true,
|
||||
activitypub: false
|
||||
}));
|
||||
|
||||
labs.isSet('members').should.be.true;
|
||||
labs.isSet('activitypub').should.be.false;
|
||||
assert.equal(labs.isSet('members'), true);
|
||||
assert.equal(labs.isSet('activitypub'), false);
|
||||
});
|
||||
|
||||
it('members flag is false when members_signup_access setting is "none"', function () {
|
||||
sinon.stub(settingsCache, 'get');
|
||||
settingsCache.get.withArgs('members_signup_access').returns('none');
|
||||
|
||||
labs.getAll().should.eql(expectedLabsObject({
|
||||
assert.deepEqual(labs.getAll(), expectedLabsObject({
|
||||
members: false
|
||||
}));
|
||||
|
||||
labs.isSet('members').should.be.false;
|
||||
assert.equal(labs.isSet('members'), false);
|
||||
});
|
||||
|
||||
it('isSet returns false for undefined', function () {
|
||||
labs.isSet('bar').should.be.false;
|
||||
assert.equal(labs.isSet('bar'), false);
|
||||
});
|
||||
|
||||
it('isSet always returns false for deprecated', function () {
|
||||
labs.isSet('subscribers').should.be.false;
|
||||
labs.isSet('publicAPI').should.be.false;
|
||||
assert.equal(labs.isSet('subscribers'), false);
|
||||
assert.equal(labs.isSet('publicAPI'), false);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue