mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-04 20:42:52 +00:00
test: add tests concerning the translators cache
This commit is contained in:
committed by
Jovan Krunić
parent
cf83692e71
commit
6f12fbda94
@@ -218,6 +218,25 @@ export class TranslationSpecInplace {
|
||||
expect(translator.translate(dish).offers[0].inPlace.categories[1234]('printer')).to.equal('printer');
|
||||
expect(translator.translate(dish).offers[0].inPlace.categories[1]('printer')).to.not.equal('printer');
|
||||
}
|
||||
|
||||
@test
|
||||
public changingTranslatorLanguageFlushesItsLRUCache() {
|
||||
const translatorDE = new SCThingTranslator('de');
|
||||
expect(translatorDE.translate(dish).name()).to.equal('de-dish-name');
|
||||
translatorDE.language = 'en';
|
||||
expect(translatorDE.translate(dish).name()).to.equal('base-dish-name');
|
||||
}
|
||||
|
||||
@test
|
||||
public forceTranslatorLRUCacheToOverflow() {
|
||||
const translatorDE = new SCThingTranslator('de');
|
||||
// Make sure to add more elements to the translator cache than the maximum cache capacity. See Translator.ts
|
||||
for (let i = 0; i < 201; i++) {
|
||||
const anotherDish = Object.assign({}, dish);
|
||||
anotherDish.uid = String(i);
|
||||
expect(translatorDE.translate(anotherDish).name()).to.equal('de-dish-name');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:member-ordering no-eval no-unused-expression TranslationSpec
|
||||
|
||||
Reference in New Issue
Block a user