Fix(challenges): Only show beta on map in dev

This commit is contained in:
Berkeley Martinez
2016-09-09 14:52:34 -07:00
parent efc76f7f71
commit 26875725db
3 changed files with 125 additions and 3 deletions

View File

@@ -4,6 +4,8 @@ import {
getNextChallenge,
getFirstChallengeOfNextBlock,
getFirstChallengeOfNextSuperBlock,
filterCommingSoonBetaChallenge,
filterComingSoonBetaFromEntities,
createMapUi,
traverseMapUi,
getNode,
@@ -858,6 +860,91 @@ test('common/app/routes/challenges/utils', function(t) {
);
});
});
t.test('filterCommingSoonBetaChallenge', t => {
t.plan(4);
t.test('should return true when not coming-soon/beta', t => {
let isDev;
t.ok(filterCommingSoonBetaChallenge(isDev, {}));
t.ok(filterCommingSoonBetaChallenge(true, {}));
t.end();
});
t.test('should return false when isComingSoon', t => {
let isDev;
t.notOk(filterCommingSoonBetaChallenge(isDev, { isComingSoon: true }));
t.end();
});
t.test('should return false when isBeta', t => {
let isDev;
t.notOk(filterCommingSoonBetaChallenge(isDev, { isBeta: true }));
t.end();
});
t.test('should always return true when in dev', t => {
let isDev = true;
t.ok(filterCommingSoonBetaChallenge(isDev, { isBeta: true }));
t.ok(filterCommingSoonBetaChallenge(isDev, { isComingSoon: true }));
t.ok(filterCommingSoonBetaChallenge(
isDev,
{ isBeta: true, isCompleted: true }
));
t.end();
});
});
t.test('filterComingSoonBetaFromEntities', t => {
t.plan(2);
t.test('should filter isBeta|coming-soon by default', t => {
t.plan(2);
const normalChallenge = { dashedName: 'normal-challenge' };
const entities = {
challenge: {
'coming-soon': {
isComingSoon: true
},
'is-beta': {
isBeta: true
},
[normalChallenge.dashedName]: normalChallenge
}
};
const actual = filterComingSoonBetaFromEntities(entities);
t.isEqual(
Object.keys(actual.challenge).length,
1,
'did not filter the correct amount of challenges'
);
t.isEqual(
actual.challenge[normalChallenge.dashedName],
normalChallenge,
'did not return the correct challenge'
);
});
t.test('should not filter isBeta|coming-soon when isDev', t => {
t.plan(1);
const normalChallenge = { dashedName: 'normal-challenge' };
const entities = {
challenge: {
'coming-soon': {
dashedName: 'coming-soon',
isComingSoon: true
},
'is-beta': {
dashedName: 'is-beta',
isBeta: true
},
'is-both': {
dashedName: 'is-both',
isBeta: true
},
[normalChallenge.dashedName]: normalChallenge
}
};
const actual = filterComingSoonBetaFromEntities(entities, true);
t.isEqual(
Object.keys(actual.challenge).length,
4,
'filtered challenges'
);
});
});
t.test('createMapUi', t => {
t.plan(3);
t.test('should return an `{}` when proper args not supplied', t => {