0
Fork 0
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:
Hannah Wolfe 2022-02-18 10:12:31 +00:00
parent 3ad871b21e
commit a064067154
No known key found for this signature in database
GPG key ID: AB586C3B5AE5C037

View file

@ -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) => {