mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
fix test lint
This commit is contained in:
@@ -30,12 +30,12 @@ describe('shared.ops.hatch', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow hatching if user lacks specified egg', (done) => {
|
||||
it('does not allow hatching if user lacks specified egg', done => {
|
||||
user.items.eggs.Wolf = 1;
|
||||
user.items.hatchingPotions.Base = 1;
|
||||
user.items.pets = {};
|
||||
try {
|
||||
hatch(user, {params: {egg: 'Dragon', hatchingPotion: 'Base'}});
|
||||
hatch(user, { params: { egg: 'Dragon', hatchingPotion: 'Base' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('messageMissingEggPotion'));
|
||||
@@ -46,12 +46,12 @@ describe('shared.ops.hatch', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow hatching if user lacks specified hatching potion', (done) => {
|
||||
it('does not allow hatching if user lacks specified hatching potion', done => {
|
||||
user.items.eggs.Wolf = 1;
|
||||
user.items.hatchingPotions.Base = 1;
|
||||
user.items.pets = {};
|
||||
try {
|
||||
hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Golden'}});
|
||||
hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Golden' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotFound);
|
||||
expect(err.message).to.equal(i18n.t('messageMissingEggPotion'));
|
||||
@@ -62,50 +62,50 @@ describe('shared.ops.hatch', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow hatching if user already owns target pet', (done) => {
|
||||
user.items.eggs = {Wolf: 1};
|
||||
user.items.hatchingPotions = {Base: 1};
|
||||
user.items.pets = {'Wolf-Base': 10};
|
||||
it('does not allow hatching if user already owns target pet', done => {
|
||||
user.items.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Base: 1 };
|
||||
user.items.pets = { 'Wolf-Base': 10 };
|
||||
try {
|
||||
hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Base'}});
|
||||
hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Base' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||
expect(err.message).to.equal(i18n.t('messageAlreadyPet'));
|
||||
expect(user.items.pets).to.eql({'Wolf-Base': 10});
|
||||
expect(user.items.eggs).to.eql({Wolf: 1});
|
||||
expect(user.items.hatchingPotions).to.eql({Base: 1});
|
||||
expect(user.items.pets).to.eql({ 'Wolf-Base': 10 });
|
||||
expect(user.items.eggs).to.eql({ Wolf: 1 });
|
||||
expect(user.items.hatchingPotions).to.eql({ Base: 1 });
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow hatching quest pet egg using premium potion', (done) => {
|
||||
user.items.eggs = {Cheetah: 1};
|
||||
user.items.hatchingPotions = {Spooky: 1};
|
||||
it('does not allow hatching quest pet egg using premium potion', done => {
|
||||
user.items.eggs = { Cheetah: 1 };
|
||||
user.items.hatchingPotions = { Spooky: 1 };
|
||||
user.items.pets = {};
|
||||
try {
|
||||
hatch(user, {params: {egg: 'Cheetah', hatchingPotion: 'Spooky'}});
|
||||
hatch(user, { params: { egg: 'Cheetah', hatchingPotion: 'Spooky' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('messageInvalidEggPotionCombo'));
|
||||
expect(user.items.pets).to.be.empty;
|
||||
expect(user.items.eggs).to.eql({Cheetah: 1});
|
||||
expect(user.items.hatchingPotions).to.eql({Spooky: 1});
|
||||
expect(user.items.eggs).to.eql({ Cheetah: 1 });
|
||||
expect(user.items.hatchingPotions).to.eql({ Spooky: 1 });
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('does not allow hatching quest pet egg using wacky potion', (done) => {
|
||||
user.items.eggs = {Bunny: 1};
|
||||
user.items.hatchingPotions = {Veggie: 1};
|
||||
it('does not allow hatching quest pet egg using wacky potion', done => {
|
||||
user.items.eggs = { Bunny: 1 };
|
||||
user.items.hatchingPotions = { Veggie: 1 };
|
||||
user.items.pets = {};
|
||||
try {
|
||||
hatch(user, {params: {egg: 'Bunny', hatchingPotion: 'Veggie'}});
|
||||
hatch(user, { params: { egg: 'Bunny', hatchingPotion: 'Veggie' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('messageInvalidEggPotionCombo'));
|
||||
expect(user.items.pets).to.be.empty;
|
||||
expect(user.items.eggs).to.eql({Bunny: 1});
|
||||
expect(user.items.hatchingPotions).to.eql({Veggie: 1});
|
||||
expect(user.items.eggs).to.eql({ Bunny: 1 });
|
||||
expect(user.items.hatchingPotions).to.eql({ Veggie: 1 });
|
||||
done();
|
||||
}
|
||||
});
|
||||
@@ -113,51 +113,51 @@ describe('shared.ops.hatch', () => {
|
||||
|
||||
context('successful hatching', () => {
|
||||
it('hatches a basic pet', () => {
|
||||
user.items.eggs = {Wolf: 1};
|
||||
user.items.hatchingPotions = {Base: 1};
|
||||
user.items.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Base: 1 };
|
||||
user.items.pets = {};
|
||||
let [data, message] = hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Base'}});
|
||||
const [data, message] = hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Base' } });
|
||||
expect(message).to.equal(i18n.t('messageHatched'));
|
||||
expect(data).to.eql(user.items);
|
||||
expect(user.items.pets).to.eql({'Wolf-Base': 5});
|
||||
expect(user.items.eggs).to.eql({Wolf: 0});
|
||||
expect(user.items.hatchingPotions).to.eql({Base: 0});
|
||||
expect(user.items.pets).to.eql({ 'Wolf-Base': 5 });
|
||||
expect(user.items.eggs).to.eql({ Wolf: 0 });
|
||||
expect(user.items.hatchingPotions).to.eql({ Base: 0 });
|
||||
});
|
||||
|
||||
it('hatches a quest pet', () => {
|
||||
user.items.eggs = {Cheetah: 1};
|
||||
user.items.hatchingPotions = {Base: 1};
|
||||
user.items.eggs = { Cheetah: 1 };
|
||||
user.items.hatchingPotions = { Base: 1 };
|
||||
user.items.pets = {};
|
||||
let [data, message] = hatch(user, {params: {egg: 'Cheetah', hatchingPotion: 'Base'}});
|
||||
const [data, message] = hatch(user, { params: { egg: 'Cheetah', hatchingPotion: 'Base' } });
|
||||
expect(message).to.equal(i18n.t('messageHatched'));
|
||||
expect(data).to.eql(user.items);
|
||||
expect(user.items.pets).to.eql({'Cheetah-Base': 5});
|
||||
expect(user.items.eggs).to.eql({Cheetah: 0});
|
||||
expect(user.items.hatchingPotions).to.eql({Base: 0});
|
||||
expect(user.items.pets).to.eql({ 'Cheetah-Base': 5 });
|
||||
expect(user.items.eggs).to.eql({ Cheetah: 0 });
|
||||
expect(user.items.hatchingPotions).to.eql({ Base: 0 });
|
||||
});
|
||||
|
||||
it('hatches a premium pet', () => {
|
||||
user.items.eggs = {Wolf: 1};
|
||||
user.items.hatchingPotions = {Spooky: 1};
|
||||
user.items.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Spooky: 1 };
|
||||
user.items.pets = {};
|
||||
let [data, message] = hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Spooky'}});
|
||||
const [data, message] = hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Spooky' } });
|
||||
expect(message).to.equal(i18n.t('messageHatched'));
|
||||
expect(data).to.eql(user.items);
|
||||
expect(user.items.pets).to.eql({'Wolf-Spooky': 5});
|
||||
expect(user.items.eggs).to.eql({Wolf: 0});
|
||||
expect(user.items.hatchingPotions).to.eql({Spooky: 0});
|
||||
expect(user.items.pets).to.eql({ 'Wolf-Spooky': 5 });
|
||||
expect(user.items.eggs).to.eql({ Wolf: 0 });
|
||||
expect(user.items.hatchingPotions).to.eql({ Spooky: 0 });
|
||||
});
|
||||
|
||||
it('hatches a pet previously raised to a mount', () => {
|
||||
user.items.eggs = {Wolf: 1};
|
||||
user.items.hatchingPotions = {Base: 1};
|
||||
user.items.pets = {'Wolf-Base': -1};
|
||||
let [data, message] = hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Base'}});
|
||||
user.items.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Base: 1 };
|
||||
user.items.pets = { 'Wolf-Base': -1 };
|
||||
const [data, message] = hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Base' } });
|
||||
expect(message).to.eql(i18n.t('messageHatched'));
|
||||
expect(data).to.eql(user.items);
|
||||
expect(user.items.pets).to.eql({'Wolf-Base': 5});
|
||||
expect(user.items.eggs).to.eql({Wolf: 0});
|
||||
expect(user.items.hatchingPotions).to.eql({Base: 0});
|
||||
expect(user.items.pets).to.eql({ 'Wolf-Base': 5 });
|
||||
expect(user.items.eggs).to.eql({ Wolf: 0 });
|
||||
expect(user.items.hatchingPotions).to.eql({ Base: 0 });
|
||||
});
|
||||
|
||||
it('awards Back to Basics achievement', () => {
|
||||
@@ -172,9 +172,9 @@ describe('shared.ops.hatch', () => {
|
||||
'Cactus-Base': 15,
|
||||
'BearCub-Base': 5,
|
||||
};
|
||||
user.items.eggs = {Wolf: 1};
|
||||
user.items.hatchingPotions = {Spooky: 1};
|
||||
hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Spooky'}});
|
||||
user.items.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Spooky: 1 };
|
||||
hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Spooky' } });
|
||||
expect(user.achievements.backToBasics).to.eql(true);
|
||||
});
|
||||
|
||||
@@ -190,9 +190,9 @@ describe('shared.ops.hatch', () => {
|
||||
'Cactus-Desert': 15,
|
||||
'BearCub-Desert': 5,
|
||||
};
|
||||
user.items.eggs = {Wolf: 1};
|
||||
user.items.hatchingPotions = {Spooky: 1};
|
||||
hatch(user, {params: {egg: 'Wolf', hatchingPotion: 'Spooky'}});
|
||||
user.items.eggs = { Wolf: 1 };
|
||||
user.items.hatchingPotions = { Spooky: 1 };
|
||||
hatch(user, { params: { egg: 'Wolf', hatchingPotion: 'Spooky' } });
|
||||
expect(user.achievements.dustDevil).to.eql(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user