mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
test fixes
This commit is contained in:
@@ -38,22 +38,22 @@ describe('armoire', () => {
|
||||
const items = makeArmoireIitemList();
|
||||
expect(items.length).to.equal(377);
|
||||
forEach(items, item => {
|
||||
expect(item.released).to.be.true;
|
||||
expect(item.released, item.key).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
it('released gear has all required properties', async () => {
|
||||
clock = sinon.useFakeTimers(new Date('2024-05-08'));
|
||||
const items = makeArmoireIitemList();
|
||||
expect(items.length).to.equal(392);
|
||||
expect(items.length).to.equal(396);
|
||||
forEach(items, item => {
|
||||
if (item.set !== undefined) {
|
||||
expect(item.set).to.be.a('string');
|
||||
expect(item.set).to.not.be.empty;
|
||||
expect(item.set, item.key).to.be.a('string');
|
||||
expect(item.set, item.key).to.not.be.empty;
|
||||
}
|
||||
expectValidTranslationString(item.text);
|
||||
expect(item.released).to.be.a('boolean');
|
||||
expect(item.value).to.be.a('number');
|
||||
expect(item.released, item.key).to.be.a('boolean');
|
||||
expect(item.value, item.key).to.be.a('number');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
expectValidTranslationString,
|
||||
} from '../helpers/content.helper';
|
||||
|
||||
import { CLASSES } from '../../website/common/script/content/constants';
|
||||
|
||||
import gearData from '../../website/common/script/content/gear';
|
||||
import * as backerGear from '../../website/common/script/content/gear/sets/special/special-backer';
|
||||
import * as contributorGear from '../../website/common/script/content/gear/sets/special/special-contributor';
|
||||
@@ -17,35 +19,48 @@ describe('Gear', () => {
|
||||
context(`${klass} ${gearType}s`, () => {
|
||||
it('have a value of at least 0 for each stat', () => {
|
||||
each(items, gear => {
|
||||
expect(gear.con).to.be.at.least(0);
|
||||
expect(gear.int).to.be.at.least(0);
|
||||
expect(gear.per).to.be.at.least(0);
|
||||
expect(gear.str).to.be.at.least(0);
|
||||
expect(gear.con, gear.key).to.be.at.least(0);
|
||||
expect(gear.int, gear.key).to.be.at.least(0);
|
||||
expect(gear.per, gear.key).to.be.at.least(0);
|
||||
expect(gear.str, gear.key).to.be.at.least(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('have a purchase value of at least 0', () => {
|
||||
each(items, gear => {
|
||||
expect(gear.value).to.be.at.least(0);
|
||||
expect(gear.value, gear.key).to.be.at.least(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('has a canBuy function', () => {
|
||||
each(items, gear => {
|
||||
expect(gear.canBuy).to.be.a('function');
|
||||
expect(gear.canBuy, gear.key).to.be.a('function');
|
||||
});
|
||||
});
|
||||
|
||||
it('have valid translation strings for text and notes', () => {
|
||||
each(items, gear => {
|
||||
expectValidTranslationString(gear.text);
|
||||
expectValidTranslationString(gear.notes);
|
||||
expectValidTranslationString(gear.text, gear.key);
|
||||
expectValidTranslationString(gear.notes, gear.key);
|
||||
});
|
||||
});
|
||||
|
||||
it('has a set attribue', () => {
|
||||
each(items, gear => {
|
||||
expect(gear.set).to.exist;
|
||||
expect(gear.set, gear.key).to.exist;
|
||||
});
|
||||
});
|
||||
|
||||
it('has a valid value for klass or specialClass', () => {
|
||||
const validClassValues = CLASSES + ['base', 'mystery', 'armoire'];
|
||||
each(items, gear => {
|
||||
const field = gear.klass === 'special' ? gear.specialClass : gear.klass;
|
||||
if (gear.klass === 'special' && field === undefined) {
|
||||
// some special gear doesn't have a klass
|
||||
return;
|
||||
}
|
||||
expect(field, gear.key).to.exist;
|
||||
expect(validClassValues, gear.key).to.include(field);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -96,31 +96,31 @@ describe('Content Schedule', () => {
|
||||
it('sets the end date if its in the same month', () => {
|
||||
const date = new Date('2024-04-03');
|
||||
const matchers = getAllScheduleMatchingGroups(date);
|
||||
expect(matchers.backgrounds.end).to.eql(moment('2024-04-07').toDate());
|
||||
expect(matchers.backgrounds.end).to.eql(moment.utc('2024-04-07').toDate());
|
||||
});
|
||||
|
||||
it('sets the end date if its in the next day', () => {
|
||||
const date = new Date('2024-05-06T14:00:00.000Z');
|
||||
const matchers = getAllScheduleMatchingGroups(date);
|
||||
expect(matchers.backgrounds.end).to.eql(moment('2024-05-07').toDate());
|
||||
expect(matchers.backgrounds.end).to.eql(moment.utc('2024-05-07').toDate());
|
||||
});
|
||||
|
||||
it('sets the end date if its on the release day', () => {
|
||||
const date = new Date('2024-05-07');
|
||||
const matchers = getAllScheduleMatchingGroups(date);
|
||||
expect(matchers.backgrounds.end).to.eql(moment('2024-06-07').toDate());
|
||||
expect(matchers.backgrounds.end).to.eql(moment.utc('2024-06-07').toDate());
|
||||
});
|
||||
|
||||
it('sets the end date if its next month', () => {
|
||||
const date = new Date('2024-05-20T01:00:00.000Z');
|
||||
const matchers = getAllScheduleMatchingGroups(date);
|
||||
expect(matchers.backgrounds.end).to.eql(moment('2024-06-07').toDate());
|
||||
expect(matchers.backgrounds.end).to.eql(moment.utc('2024-06-07').toDate());
|
||||
});
|
||||
|
||||
it('sets the end date for a gala', () => {
|
||||
const date = new Date('2024-05-20');
|
||||
const matchers = getAllScheduleMatchingGroups(date);
|
||||
expect(matchers.seasonalGear.end).to.eql(moment('2024-06-21').toDate());
|
||||
expect(matchers.seasonalGear.end).to.eql(moment.utc('2024-06-21').toDate());
|
||||
});
|
||||
|
||||
it('contains content for repeating events', () => {
|
||||
|
||||
@@ -7,13 +7,13 @@ i18n.translations = translations;
|
||||
export const STRING_ERROR_MSG = /^Error processing the string ".*". Please see Help > Report a Bug.$/;
|
||||
export const STRING_DOES_NOT_EXIST_MSG = /^String '.*' not found.$/;
|
||||
|
||||
export function expectValidTranslationString (attribute) {
|
||||
expect(attribute).to.be.a('function');
|
||||
export function expectValidTranslationString (attribute, contextKey) {
|
||||
expect(attribute, contextKey).to.be.a('function');
|
||||
|
||||
const translatedString = attribute();
|
||||
|
||||
expect(translatedString.trim()).to.not.be.empty;
|
||||
expect(translatedString).to.not.contain('function func(lang)');
|
||||
expect(translatedString).to.not.eql(STRING_ERROR_MSG);
|
||||
expect(translatedString).to.not.match(STRING_DOES_NOT_EXIST_MSG);
|
||||
expect(translatedString.trim(), contextKey).to.not.be.empty;
|
||||
expect(translatedString, contextKey).to.not.contain('function func(lang)');
|
||||
expect(translatedString, contextKey).to.not.eql(STRING_ERROR_MSG);
|
||||
expect(translatedString, contextKey).to.not.match(STRING_DOES_NOT_EXIST_MSG);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user