Merge branch 'develop' into TheHollidayInn-skills-burst-backstap-leveling-fix

This commit is contained in:
Blade Barringer
2015-12-13 10:06:27 -06:00
780 changed files with 14452 additions and 11296 deletions
+2 -1
View File
@@ -70,7 +70,8 @@ describe('In-App Purchases', function() {
expect(paymentSpy).to.be.calledOnce;
return expect(paymentSpy).to.be.calledWith({
user: res.locals.user,
paymentMethod: 'IAP GooglePlay'
paymentMethod: 'IAP GooglePlay',
amount: 5.25
});
});
});
@@ -240,4 +240,55 @@ describe('POST /register', () => {
});
});
});
context('successful login with habitica-android header', () => {
let api, username, email, password;
beforeEach(() => {
api = requester({}, {'x-client': 'habitica-android'});
username = generateRandomUserName();
email = `${username}@example.com`;
password = 'password';
});
it('sets all common tutorial flags to true', () => {
return api.post('/register', {
username: username,
email: email,
password: password,
confirmPassword: password,
}).then((user) => {
expect(user.flags.tour).to.not.be.empty;
each(user.flags.tutorial.common, (value, attribute) => {
expect(value).to.eql(true);
});
});
});
it('populates user with default todos, habits, and rewards', () => {
return api.post('/register', {
username: username,
email: email,
password: password,
confirmPassword: password,
}).then((user) => {
expect(user.todos).to.not.be.empty;
expect(user.dailys).to.be.empty;
expect(user.habits).to.not.be.empty;
expect(user.rewards).to.not.be.empty;
});
});
it('populates user with default tags', () => {
return api.post('/register', {
username: username,
email: email,
password: password,
confirmPassword: password,
}).then((user) => {
expect(user.tags).to.not.be.empty;
});
});
});
});
+102
View File
@@ -0,0 +1,102 @@
/* eslint-disable camelcase */
import sinon from 'sinon'; // eslint-disable-line no-shadow
import {assert} from 'sinon';
import i18n from '../../common/script/i18n';
import shared from '../../common/script/index.js';
import content from '../../common/script/content/index';
describe('user.ops.equip', () => {
let user;
let spy;
beforeEach(() => {
user = {
items: {
gear: {
owned: {
weapon_warrior_0: true,
weapon_warrior_1: true,
weapon_warrior_2: true,
weapon_wizard_1: true,
weapon_wizard_2: true,
shield_base_0: true,
shield_warrior_1: true,
},
equipped: {
weapon: 'weapon_warrior_0',
shield: 'shield_base_0',
},
},
},
preferences: {},
stats: {gp: 200},
achievements: {},
flags: {},
};
shared.wrap(user);
spy = sinon.spy();
});
context('Gear', () => {
it('should not send a message if a weapon is equipped while only having zero or one weapons equipped', () => {
// user.ops.equip always calls the callback, even if it isn't sending a message
// so we need to check to see if a single null message was sent.
user.ops.equip({params: {key: 'weapon_warrior_1'}});
// one-handed to one-handed
user.ops.equip({params: {key: 'weapon_warrior_2'}}, spy);
assert.calledOnce(spy);
assert.calledWith(spy, null);
spy.reset();
// one-handed to two-handed
user.ops.equip({params: {key: 'weapon_wizard_1'}}, spy);
assert.calledOnce(spy);
assert.calledWith(spy, null);
spy.reset();
// two-handed to two-handed
user.ops.equip({params: {key: 'weapon_wizard_2'}}, spy);
assert.calledOnce(spy);
assert.calledWith(spy, null);
spy.reset();
// two-handed to one-handed
user.ops.equip({params: {key: 'weapon_warrior_2'}}, spy);
assert.calledOnce(spy);
assert.calledWith(spy, null);
spy.reset();
});
it('should send messages if equipping a two-hander causes the off-hander to be unequipped', () => {
user.ops.equip({params: {key: 'weapon_warrior_1'}});
user.ops.equip({params: {key: 'shield_warrior_1'}});
// equipping two-hander
user.ops.equip({params: {key: 'weapon_wizard_1'}}, spy);
let weapon = content.gear.flat.weapon_wizard_1;
let item = content.gear.flat.shield_warrior_1;
let message = i18n.t('messageTwoHandedEquip', {twoHandedText: weapon.text(null), offHandedText: item.text(null)});
assert.calledOnce(spy);
assert.calledWith(spy, {code: 200, message});
});
it('should send messages if equipping an off-hand item causes a two-handed weapon to be unequipped', () => {
// equipping two-hander
user.ops.equip({params: {key: 'weapon_wizard_1'}});
let weapon = content.gear.flat.weapon_wizard_1;
let shield = content.gear.flat.shield_warrior_1;
user.ops.equip({params: {key: 'shield_warrior_1'}}, spy);
let message = i18n.t('messageTwoHandedUnequip', {twoHandedText: weapon.text(null), offHandedText: shield.text(null)});
assert.calledOnce(spy);
assert.calledWith(spy, {code: 200, message});
});
});
});
+1 -1
View File
@@ -37,7 +37,7 @@ describe('front page', function() {
var login = element(by.css("#loginForm input[value='Login']"));
login.click();
var alertDialog = browser.switchTo().alert();
expect(alertDialog.getText()).toMatch("Uh-oh - your username or password is incorrect.\n- Make sure your username or email is typed correctly.\n- You may have signed up with Facebook, not email. Double-check by trying Facebook login.\n- If you forgot your password, click \"Forgot Password\".");
expect(alertDialog.getText()).toMatch("Uh-oh - your username or password is incorrect.\n- Make sure your username or email is typed correctly.\n- You may have signed up with Facebook, not email. Double-check by trying Facebook login.\n- If you forgot your password, click \"Forgot Password\" on the habitica.com website's login form.");
alertDialog.accept();
});
+17 -7
View File
@@ -79,18 +79,28 @@ describe('Inventory Controller', function() {
expect(rootScope.openModal).to.have.been.calledWith('hatchPet');
});
it('does not show modal if user tries to hatch a pet they own', function(){
it('shows modal even if user has raised that pet to a mount', function(){
user.items.pets['Cactus-Base'] = -1;
scope.chooseEgg('Cactus');
scope.choosePotion('Base');
expect(user.items.eggs).to.eql({Cactus: 0});
expect(user.items.hatchingPotions).to.eql({Base: 0});
expect(user.items.pets).to.eql({'Cactus-Base': 5});
expect(scope.selectedEgg).to.eql(null);
expect(scope.selectedPotion).to.eql(null);
expect(rootScope.openModal).to.have.been.calledOnce;
expect(rootScope.openModal).to.have.been.calledWith('hatchPet');
});
it('does not show modal if user tries to hatch a pet they own', function(){
user.items.pets['Cactus-Base'] = 5;
scope.chooseEgg('Cactus');
scope.choosePotion('Base');
expect(rootScope.openModal).to.not.have.been.calledTwice;
expect(rootScope.openModal).to.not.have.been.called;
});
it('does not show modal if user tries to hatch a premium quest pet', function(){
user.items.eggs = {Snake: 1};
user.items.hatchingPotions = {Peppermint: 1};
scope.chooseEgg('Snake');
scope.choosePotion('Peppermint');
expect(rootScope.openModal).to.not.have.been.called;
});
it('does not show pet hatching modal if user has opted out', function(){