mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Fixed logic error in labs mock
- the previous logic only allowed one flag to be mocked at a time because it kept recalling sinon.stub - now it's possible to mock multiple flags with different settings as we always just add to the same stub
This commit is contained in:
parent
3ad871b21e
commit
a064067154
1 changed files with 8 additions and 12 deletions
|
@ -42,33 +42,29 @@ const setupStripe = () => {
|
|||
};
|
||||
|
||||
const mockLabsEnabled = (flag, alpha = true) => {
|
||||
mocks.labs = mocks.labs || {};
|
||||
|
||||
// We assume we should enable alpha experiments unless explicitly told not to!
|
||||
if (!alpha) {
|
||||
configUtils.set('enableDeveloperExperiments', true);
|
||||
}
|
||||
|
||||
if (mocks.labs[flag]) {
|
||||
mocks.labs[flag].returns(true);
|
||||
} else {
|
||||
mocks.labs[flag] = sinon.stub(labs, 'isSet').withArgs(flag).returns(true);
|
||||
if (!mocks.labs) {
|
||||
mocks.labs = sinon.stub(labs, 'isSet');
|
||||
}
|
||||
|
||||
mocks.labs.withArgs(flag).returns(true);
|
||||
};
|
||||
|
||||
const mockLabsDisabled = (flag, alpha = true) => {
|
||||
mocks.labs = mocks.labs || {};
|
||||
|
||||
// We assume we should enable alpha experiments unless explicitly told not to!
|
||||
if (!alpha) {
|
||||
configUtils.set('enableDeveloperExperiments', true);
|
||||
}
|
||||
|
||||
if (mocks.labs[flag]) {
|
||||
mocks.labs[flag].returns(false);
|
||||
} else {
|
||||
mocks.labs[flag] = sinon.stub(labs, 'isSet').withArgs(flag).returns(false);
|
||||
if (!mocks.labs) {
|
||||
mocks.labs = sinon.stub(labs, 'isSet');
|
||||
}
|
||||
|
||||
mocks.labs.withArgs(flag).returns(false);
|
||||
};
|
||||
|
||||
const sentEmailCount = (count) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue