Adventure Guide Prep (#11883)

* WIP(adventure): prereqs

* WIP(drops): new modal

* WIP(adventure): analytics fixes etc

* feat(adventure): random egg+potion on 2nd task

* fix(lint): noworkies

* fix(modal): correctly construct classes

* fix(tests): expectations and escape

* fix(first-drops): address comments

* fix(first-drops): don't give random drops until first drops

* fix(drops): remove more Level 3 references

* refactor(drops): no need for cloning

* refactor(drops): unnecessary export

* fix(first-drops): force sync

* fix(first-drops): move to server

* fix(first-drops): escape in case we get here with >0 items

* fix(lint): line length

* fix(pet-food): remove unused string
This commit is contained in:
Sabe Jones
2020-03-07 13:03:13 -06:00
committed by GitHub
parent db1bda1bcd
commit bd8e67a2ea
31 changed files with 273 additions and 144 deletions

View File

@@ -15,6 +15,7 @@ describe('common.fns.randomDrop', () => {
beforeEach(() => {
user = generateUser();
user._tmp = user._tmp ? user._tmp : {};
user.items.eggs.Wolf = 0;
task = generateTodo({ userId: user._id });
predictableRandom = sandbox.stub().returns(0.5);
});
@@ -34,10 +35,17 @@ describe('common.fns.randomDrop', () => {
context('drops enabled', () => {
beforeEach(() => {
user.flags.dropsEnabled = true;
task.priority = 100000;
});
it('awards an egg and a hatching potion if user has never received any', () => {
delete user.items.eggs.Wolf;
randomDrop(user, { task, predictableRandom });
expect(user._tmp.firstDrops.egg).to.be.a.string;
expect(user._tmp.firstDrops.hatchingPotion).to.be.a.string;
});
it('does nothing if user.items.lastDrop.count is exceeded', () => {
user.items.lastDrop.count = 100;
randomDrop(user, { task, predictableRandom });
@@ -46,7 +54,6 @@ describe('common.fns.randomDrop', () => {
it('drops something when the task is a todo', () => {
expect(user._tmp).to.eql({});
user.flags.dropsEnabled = true;
predictableRandom.returns(0.1);
randomDrop(user, { task, predictableRandom });
@@ -56,7 +63,6 @@ describe('common.fns.randomDrop', () => {
it('drops something when the task is a habit', () => {
task = generateHabit({ userId: user._id });
expect(user._tmp).to.eql({});
user.flags.dropsEnabled = true;
predictableRandom.returns(0.1);
randomDrop(user, { task, predictableRandom });
@@ -66,7 +72,6 @@ describe('common.fns.randomDrop', () => {
it('drops something when the task is a daily', () => {
task = generateDaily({ userId: user._id });
expect(user._tmp).to.eql({});
user.flags.dropsEnabled = true;
predictableRandom.returns(0.1);
randomDrop(user, { task, predictableRandom });
@@ -76,7 +81,6 @@ describe('common.fns.randomDrop', () => {
it('drops something when the task is a reward', () => {
task = generateReward({ userId: user._id });
expect(user._tmp).to.eql({});
user.flags.dropsEnabled = true;
predictableRandom.returns(0.1);
randomDrop(user, { task, predictableRandom });