mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
Fix lint and test
This commit is contained in:
committed by
Sabe Jones
parent
d11e95ab26
commit
93011f182f
@@ -34,7 +34,7 @@ describe('contentLib', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('generates a hash for a filter', () => {
|
it('generates a hash for a filter', () => {
|
||||||
const hash = contentLib.hashForFilter('backgroundsFlat,gear.flat');
|
const hash = contentLib.hashForFilter(['backgroundsFlat', 'gear.flat']);
|
||||||
expect(hash).to.equal('-1791877526');
|
expect(hash).to.equal('-1791877526');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ describe('contentLib', () => {
|
|||||||
|
|
||||||
it('serves filtered content', () => {
|
it('serves filtered content', () => {
|
||||||
const resSpy = generateRes();
|
const resSpy = generateRes();
|
||||||
contentLib.serveContent(resSpy, 'en', 'backgroundsFlat,gear.flat', false);
|
contentLib.serveContent(resSpy, 'en', ['backgroundsFlat', 'gear.flat'], false);
|
||||||
expect(resSpy.send).to.have.been.calledOnce;
|
expect(resSpy.send).to.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ describe('contentLib', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('caches filtered requests', async () => {
|
it('caches filtered requests', async () => {
|
||||||
const filter = 'backgroundsFlat,gear.flat';
|
const filter = ['backgroundsFlat', 'gear.flat'];
|
||||||
const hash = contentLib.hashForFilter(filter);
|
const hash = contentLib.hashForFilter(filter);
|
||||||
expect(fs.existsSync(`${contentLib.CONTENT_CACHE_PATH}en${hash}.json`)).to.be.false;
|
expect(fs.existsSync(`${contentLib.CONTENT_CACHE_PATH}en${hash}.json`)).to.be.false;
|
||||||
contentLib.serveContent(resSpy, 'en', filter, true);
|
contentLib.serveContent(resSpy, 'en', filter, true);
|
||||||
@@ -89,7 +89,7 @@ describe('contentLib', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('serves filtered cached requests', async () => {
|
it('serves filtered cached requests', async () => {
|
||||||
const filter = 'backgroundsFlat,gear.flat';
|
const filter = ['backgroundsFlat', 'gear.flat'];
|
||||||
const hash = contentLib.hashForFilter(filter);
|
const hash = contentLib.hashForFilter(filter);
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
`${contentLib.CONTENT_CACHE_PATH}en${hash}.json`,
|
`${contentLib.CONTENT_CACHE_PATH}en${hash}.json`,
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ const IS_PROD = nconf.get('IS_PROD');
|
|||||||
const api = {};
|
const api = {};
|
||||||
|
|
||||||
const MOBILE_FILTER = ['achievements', 'questSeriesAchievements', 'animalColorAchievements', 'animalSetAchievements',
|
const MOBILE_FILTER = ['achievements', 'questSeriesAchievements', 'animalColorAchievements', 'animalSetAchievements',
|
||||||
'stableAchievements', 'mystery', 'bundles', 'loginIncentives', 'pets', 'premiumPets', 'specialPets', 'questPets',
|
'stableAchievements', 'mystery', 'bundles', 'loginIncentives', 'pets', 'premiumPets', 'specialPets', 'questPets',
|
||||||
'wackyPets', 'mounts', 'premiumMounts,specialMounts,questMounts', 'events', 'dropEggs', 'questEggs', 'dropHatchingPotions',
|
'wackyPets', 'mounts', 'premiumMounts,specialMounts,questMounts', 'events', 'dropEggs', 'questEggs', 'dropHatchingPotions',
|
||||||
'premiumHatchingPotions', 'wackyHatchingPotions', 'backgroundsFlat', 'questsByLevel', 'gear.tree', 'tasksByCategory',
|
'premiumHatchingPotions', 'wackyHatchingPotions', 'backgroundsFlat', 'questsByLevel', 'gear.tree', 'tasksByCategory',
|
||||||
'userDefaults', 'timeTravelStable', 'gearTypes', 'cardTypes'];
|
'userDefaults', 'timeTravelStable', 'gearTypes', 'cardTypes'];
|
||||||
|
|
||||||
const ANDROID_FILTER = [...MOBILE_FILTER, 'appearances.background'];
|
const ANDROID_FILTER = [...MOBILE_FILTER, 'appearances.background'];
|
||||||
const IOS_FILTER = [...MOBILE_FILTER, 'backgrounds'];
|
const IOS_FILTER = [...MOBILE_FILTER, 'backgrounds'];
|
||||||
@@ -74,20 +74,20 @@ api.getContent = {
|
|||||||
language = proposedLang;
|
language = proposedLang;
|
||||||
}
|
}
|
||||||
|
|
||||||
let filter_list = [];
|
let filterList = [];
|
||||||
let filter = req.query.filter || '';
|
const filter = req.query.filter || '';
|
||||||
// apply defaults for mobile clients
|
// apply defaults for mobile clients
|
||||||
if (filter === '') {
|
if (filter === '') {
|
||||||
if (req.headers['x-client'] === 'habitica-android') {
|
if (req.headers['x-client'] === 'habitica-android') {
|
||||||
filter_list = ANDROID_FILTER;
|
filterList = ANDROID_FILTER;
|
||||||
} else if (req.headers['x-client'] === 'habitica-ios') {
|
} else if (req.headers['x-client'] === 'habitica-ios') {
|
||||||
filter_list = IOS_FILTER;
|
filterList = IOS_FILTER;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filter_list = filter.split(',');
|
filterList = filter.split(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
serveContent(res, language, filter_list, IS_PROD);
|
serveContent(res, language, filterList, IS_PROD);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user