mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-11 12:12:55 +00:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bf1301733 | ||
|
|
827ba47892 | ||
|
|
d3b620a745 | ||
|
|
821834cfa0 | ||
|
|
c369c8520a | ||
|
|
66075ef99b | ||
|
|
7a6333aa8f | ||
|
|
e242a21e99 | ||
|
|
6fecd1e89d | ||
|
|
f6a93e668b | ||
|
|
2f96bc8569 | ||
|
|
9ce4026b1a | ||
|
|
e434b2d26e | ||
|
|
fe7f1a53ae | ||
|
|
907d61b5d2 | ||
|
|
5fb9755841 | ||
|
|
e5dd02eeca | ||
|
|
e7b4a426a9 | ||
|
|
7dd74af305 | ||
|
|
4409101647 |
@@ -37,7 +37,7 @@ audit:
|
|||||||
scheduled-audit:
|
scheduled-audit:
|
||||||
stage: audit
|
stage: audit
|
||||||
script:
|
script:
|
||||||
- npm audit
|
- npm audit --audit-level=high
|
||||||
only:
|
only:
|
||||||
- schedules
|
- schedules
|
||||||
|
|
||||||
|
|||||||
34
CHANGELOG.md
34
CHANGELOG.md
@@ -1,3 +1,37 @@
|
|||||||
|
# [0.37.0](https://gitlab.com/openstapps/core/compare/v0.36.0...v0.37.0) (2020-09-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove keyword tag from steps ([c369c85](https://gitlab.com/openstapps/core/commit/c369c8520a2eed169555a35a50ce745c08e1f9da))
|
||||||
|
* remove redundant property declaration ([66075ef](https://gitlab.com/openstapps/core/commit/66075ef99b95198a9cd5c0a396603e089221bcd9))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.36.0](https://gitlab.com/openstapps/core/compare/v0.35.0...v0.36.0) (2020-07-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add function to get translated SCThingType ([fe7f1a5](https://gitlab.com/openstapps/core/commit/fe7f1a53ae46e052e23f1b39851f1547b5a8dded))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.35.0](https://gitlab.com/openstapps/core/compare/v0.34.0...v0.35.0) (2020-05-13)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [0.34.0](https://gitlab.com/openstapps/core/compare/v0.33.0...v0.34.0) (2020-04-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add [@sortable](https://gitlab.com/sortable) tags to certain translatable properties ([f5e8856](https://gitlab.com/openstapps/core/commit/f5e88569eb75578febbcde67259c0c14563e53fe))
|
||||||
|
* annotate SCThing uid and url as filterable ([70c1a3e](https://gitlab.com/openstapps/core/commit/70c1a3eaa3d1c88f4b86f0df86d0d362ad1f930c))
|
||||||
|
* Update src/things/book.ts - made ISBN optional ([6060113](https://gitlab.com/openstapps/core/commit/6060113df56b871bb5014a8a961974895e52158f))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [0.33.0](https://gitlab.com/openstapps/core/compare/v0.32.0...v0.33.0) (2020-02-11)
|
# [0.33.0](https://gitlab.com/openstapps/core/compare/v0.32.0...v0.33.0) (2020-02-11)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4058
package-lock.json
generated
4058
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
39
package.json
39
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/core",
|
"name": "@openstapps/core",
|
||||||
"version": "0.34.0",
|
"version": "0.38.0",
|
||||||
"description": "StAppsCore - Generalized model of data",
|
"description": "StAppsCore - Generalized model of data",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Model",
|
"Model",
|
||||||
@@ -42,39 +42,38 @@
|
|||||||
"Roman Klopsch"
|
"Roman Klopsch"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@openstapps/core-tools": "0.16.0",
|
||||||
"@types/geojson": "1.0.6",
|
"@types/geojson": "1.0.6",
|
||||||
"@types/json-patch": "0.0.30",
|
"@types/json-patch": "0.0.30",
|
||||||
|
"@types/json-schema": "7.0.6",
|
||||||
"@types/node": "10.17.14",
|
"@types/node": "10.17.14",
|
||||||
"fast-clone": "1.5.13",
|
"fast-clone": "1.5.13",
|
||||||
"http-status-codes": "1.4.0",
|
"http-status-codes": "2.1.2",
|
||||||
"json-patch": "0.7.0",
|
"json-patch": "0.7.0",
|
||||||
"jsonschema": "1.2.5",
|
"json-schema": "0.2.5",
|
||||||
"ts-optchain": "0.1.3"
|
"ts-optchain": "0.1.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@krlwlfrt/async-pool": "0.1.0",
|
"@openstapps/configuration": "0.24.0",
|
||||||
"@openstapps/configuration": "0.23.0",
|
"@openstapps/logger": "0.5.0",
|
||||||
"@openstapps/core-tools": "0.14.0",
|
"@types/chai": "4.2.12",
|
||||||
"@openstapps/logger": "0.4.0",
|
"@types/rimraf": "3.0.0",
|
||||||
"@types/chai": "4.2.8",
|
|
||||||
"@types/rimraf": "2.0.3",
|
|
||||||
"chai": "4.2.0",
|
"chai": "4.2.0",
|
||||||
"commander": "2.20.0",
|
|
||||||
"conditional-type-checks": "1.0.5",
|
"conditional-type-checks": "1.0.5",
|
||||||
"conventional-changelog-cli": "2.0.31",
|
"conventional-changelog-cli": "2.1.0",
|
||||||
"mocha": "6.2.0",
|
"mocha": "8.1.1",
|
||||||
"mocha-typescript": "1.1.17",
|
"mocha-typescript": "1.1.17",
|
||||||
"nyc": "14.1.1",
|
"nyc": "15.1.0",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"source-map-support": "0.5.13",
|
"source-map-support": "0.5.19",
|
||||||
"ts-node": "8.6.2",
|
"ts-node": "9.0.0",
|
||||||
"tslint": "5.18.0",
|
"tslint": "6.1.3",
|
||||||
"typedoc": "0.14.2",
|
"typedoc": "0.18.0",
|
||||||
"typescript": "3.5.3"
|
"typescript": "3.8.3"
|
||||||
},
|
},
|
||||||
"nyc": {
|
"nyc": {
|
||||||
"all": true,
|
"all": true,
|
||||||
"branches": 85,
|
"branches": 90,
|
||||||
"check-coverage": true,
|
"check-coverage": true,
|
||||||
"exclude": [],
|
"exclude": [],
|
||||||
"extension": [
|
"extension": [
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
import {ValidationError} from '@openstapps/core-tools/lib/common';
|
||||||
import {BAD_REQUEST} from 'http-status-codes';
|
import {BAD_REQUEST} from 'http-status-codes';
|
||||||
import {ValidationError} from 'jsonschema';
|
|
||||||
import {SCError} from '../error';
|
import {SCError} from '../error';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {OK} from 'http-status-codes';
|
import {OK} from 'http-status-codes';
|
||||||
import {Schema} from 'jsonschema';
|
import {JSONSchema7} from 'json-schema';
|
||||||
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
import {SCInternalServerErrorResponse} from '../errors/internal-server-error';
|
||||||
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
import {SCMethodNotAllowedErrorResponse} from '../errors/method-not-allowed';
|
||||||
import {SCNotFoundErrorResponse} from '../errors/not-found';
|
import {SCNotFoundErrorResponse} from '../errors/not-found';
|
||||||
@@ -78,12 +78,12 @@ export interface SCPluginMetaData {
|
|||||||
/**
|
/**
|
||||||
* How the requests of the plugin looks like, a JSON schema for validation
|
* How the requests of the plugin looks like, a JSON schema for validation
|
||||||
*/
|
*/
|
||||||
requestSchema: Schema;
|
requestSchema: JSONSchema7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How the responses of the plugin looks like, a JSON schema for validation
|
* How the responses of the plugin looks like, a JSON schema for validation
|
||||||
*/
|
*/
|
||||||
responseSchema: Schema;
|
responseSchema: JSONSchema7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The desired route, for example /feedback.
|
* The desired route, for example /feedback.
|
||||||
|
|||||||
@@ -41,15 +41,6 @@ export type SCBuildingCategories =
|
|||||||
export interface SCBuildingWithoutReferences
|
export interface SCBuildingWithoutReferences
|
||||||
extends SCThingWithCategoriesWithoutReferences<SCBuildingCategories, SCThingWithCategoriesSpecificValues>,
|
extends SCThingWithCategoriesWithoutReferences<SCBuildingCategories, SCThingWithCategoriesSpecificValues>,
|
||||||
SCPlaceWithoutReferences {
|
SCPlaceWithoutReferences {
|
||||||
/**
|
|
||||||
* Categories of a building
|
|
||||||
*
|
|
||||||
* @sortable ducet
|
|
||||||
* @aggregatable
|
|
||||||
* @filterable
|
|
||||||
*/
|
|
||||||
categories: SCBuildingCategories[];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of floor names of the place
|
* List of floor names of the place
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -43,15 +43,6 @@ export interface SCDishWithoutReferences
|
|||||||
*/
|
*/
|
||||||
additives?: string[];
|
additives?: string[];
|
||||||
|
|
||||||
/**
|
|
||||||
* Category of the dish
|
|
||||||
*
|
|
||||||
* @sortable ducet
|
|
||||||
* @aggregatable
|
|
||||||
* @filterable
|
|
||||||
*/
|
|
||||||
categories: SCDishCategories[];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Characteristics of the dish
|
* Characteristics of the dish
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ import {
|
|||||||
*/
|
*/
|
||||||
export interface SCSettingWithoutReferences
|
export interface SCSettingWithoutReferences
|
||||||
extends SCThingWithCategoriesWithoutReferences<SCSettingCategories, SCThingWithCategoriesSpecificValues> {
|
extends SCThingWithCategoriesWithoutReferences<SCSettingCategories, SCThingWithCategoriesSpecificValues> {
|
||||||
/**
|
|
||||||
* Categories of a setting
|
|
||||||
*/
|
|
||||||
categories: SCSettingCategories[];
|
|
||||||
/**
|
/**
|
||||||
* The default value of a setting
|
* The default value of a setting
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ export interface SCTourWithoutReferences
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Steps of a tour
|
* Steps of a tour
|
||||||
*
|
|
||||||
* @keyword
|
|
||||||
*/
|
*/
|
||||||
steps: SCTourStep[];
|
steps: SCTourStep[];
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import clone = require('fast-clone');
|
import clone = require('fast-clone');
|
||||||
import {Defined, OCType} from 'ts-optchain';
|
import {Defined, TSOCType} from 'ts-optchain';
|
||||||
import {SCTranslations} from './general/i18n';
|
import {SCTranslations} from './general/i18n';
|
||||||
import {isThing} from './guards';
|
import {isThing} from './guards';
|
||||||
import {SCClasses} from './meta';
|
import {SCClasses} from './meta';
|
||||||
@@ -76,12 +76,12 @@ export class SCThingTranslator {
|
|||||||
* Get field value translation recursively
|
* Get field value translation recursively
|
||||||
*
|
*
|
||||||
* @param data The intermediate object / primitive returned by the Proxys get() method
|
* @param data The intermediate object / primitive returned by the Proxys get() method
|
||||||
* @returns an OCType<T> object allowing for access to translations or a translated value(s)
|
* @returns an TSOCType<T> object allowing for access to translations or a translated value(s)
|
||||||
*/
|
*/
|
||||||
// tslint:disable-next-line:prefer-function-over-method
|
// tslint:disable-next-line:prefer-function-over-method
|
||||||
private deeptranslate<T>(data?: T): OCType<T> {
|
private deeptranslate<T>(data?: T): TSOCType<T> {
|
||||||
const proxy = new Proxy(
|
const proxy = new Proxy(
|
||||||
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as OCType<T>,
|
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as TSOCType<T>,
|
||||||
{
|
{
|
||||||
get: (target, key) => {
|
get: (target, key) => {
|
||||||
const obj: any = target();
|
const obj: any = target();
|
||||||
@@ -189,14 +189,14 @@ export class SCThingTranslator {
|
|||||||
* // or
|
* // or
|
||||||
* const dishTranslatedAccess = translator.translate(dish);
|
* const dishTranslatedAccess = translator.translate(dish);
|
||||||
* dishTranslatedAccess.offers[0].inPlace.categories[1]();
|
* dishTranslatedAccess.offers[0].inPlace.categories[1]();
|
||||||
* // undoing the OCType<T>
|
* // undoing the TSOCType<T>
|
||||||
* const dishAsBefore: SCDish = dishTranslatedAccess()!;
|
* const dishAsBefore: SCDish = dishTranslatedAccess()!;
|
||||||
* @param data Top level object that gets passed through the recursion
|
* @param data Top level object that gets passed through the recursion
|
||||||
* @returns an OCType<T> object allowing for access to translations or a translated value(s)
|
* @returns an TSOCType<T> object allowing for access to translations or a translated value(s)
|
||||||
*/
|
*/
|
||||||
public translate<T extends SCThing>(data: T): OCType<T> {
|
public translate<T extends SCThing>(data: T): TSOCType<T> {
|
||||||
return new Proxy(
|
return new Proxy(
|
||||||
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as OCType<T>,
|
((defaultValue?: Defined<T>) => (data == null ? defaultValue : data)) as TSOCType<T>,
|
||||||
{
|
{
|
||||||
get: (target, key) => {
|
get: (target, key) => {
|
||||||
const obj: any = target();
|
const obj: any = target();
|
||||||
@@ -218,15 +218,35 @@ export class SCThingTranslator {
|
|||||||
* All the values will be set to the known translations of the property/key name
|
* All the values will be set to the known translations of the property/key name
|
||||||
* @example
|
* @example
|
||||||
* const translatedMetaDish = translator.translatedPropertyNames<SCCourseOfStudies>(SCThingType.CourseOfStudies);
|
* const translatedMetaDish = translator.translatedPropertyNames<SCCourseOfStudies>(SCThingType.CourseOfStudies);
|
||||||
* @param thing The thing whose property names will be translated
|
* @param type The type whose property names will be translated
|
||||||
* @param language The language all property names will be translated to
|
* @param language The language all property names will be translated to
|
||||||
* @returns An object with the properties of the SCThingType where the values are the known property tranlations
|
* @returns An object with the properties of the SCThingType where the values are the known property tranlations
|
||||||
*/
|
*/
|
||||||
public translatedPropertyNames<T extends SCThing>(thing: T,
|
public translatedPropertyNames<T extends SCThing>(type: SCThingType,
|
||||||
language?: keyof SCTranslations<T>): T | undefined {
|
language?: keyof SCTranslations<T>): T | undefined {
|
||||||
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
|
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
|
||||||
|
|
||||||
return this.getAllMetaFieldTranslations(thing.type, targetLanguage) as T;
|
return this.getAllMetaFieldTranslations(type, targetLanguage) as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a SCThingType this function will translate it
|
||||||
|
*
|
||||||
|
* @param type The type that will be translated
|
||||||
|
* @param language The language the type will be translated to
|
||||||
|
* @returns Known translation of type parameter
|
||||||
|
*/
|
||||||
|
public translatedThingType<T extends unknown>(type: SCThingType,
|
||||||
|
language?: keyof SCTranslations<T>): string {
|
||||||
|
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
|
||||||
|
const metaClass = this.getMetaClassInstance(type);
|
||||||
|
|
||||||
|
if (typeof metaClass.fieldValueTranslations[targetLanguage] !== 'undefined' &&
|
||||||
|
typeof metaClass.fieldValueTranslations[targetLanguage].type !== 'undefined') {
|
||||||
|
return metaClass.fieldValueTranslations[targetLanguage].type as string ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"address": "http://foo.com:1234",
|
"address": "http://foo.com:1234",
|
||||||
"name": "Foo Plugin",
|
"name": "Foo Plugin",
|
||||||
"requestSchema": {
|
"requestSchema": {
|
||||||
"$schema": "http://json-schema.org/draft-06/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"SCFooPluginRequest": {
|
"SCFooPluginRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -33,10 +33,10 @@
|
|||||||
],
|
],
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"description": "User query",
|
"description": "User query",
|
||||||
"id": "https://core.stapps.tu-berlin.de/v0.18.0/lib/schema/SCFooPluginRequest.json"
|
"$id": "https://core.stapps.tu-berlin.de/v0.18.0/lib/schema/SCFooPluginRequest.json"
|
||||||
},
|
},
|
||||||
"responseSchema": {
|
"responseSchema": {
|
||||||
"$schema": "http://json-schema.org/draft-06/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"SCFooPluginResponse": {
|
"SCFooPluginResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
],
|
],
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"description": "A response to a query",
|
"description": "A response to a query",
|
||||||
"id": "https://core.stapps.tu-berlin.de/v0.18.0/lib/schema/SCFooPluginResponse.json"
|
"$id": "https://core.stapps.tu-berlin.de/v0.18.0/lib/schema/SCFooPluginResponse.json"
|
||||||
},
|
},
|
||||||
"route": "/foo"
|
"route": "/foo"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ const languageNonExistant = eval("'jp'");
|
|||||||
// this will simulate a translator always utilizing the base language translations
|
// this will simulate a translator always utilizing the base language translations
|
||||||
const translatorWithFallback = new SCThingTranslator(languageNonExistant);
|
const translatorWithFallback = new SCThingTranslator(languageNonExistant);
|
||||||
|
|
||||||
// tslint:disable:member-ordering TranslationSpecInplace
|
// tslint:disable:max-line-length member-ordering newline-per-chained-call prefer-function-over-method completed-docs TranslationSpecInplace
|
||||||
@suite(timeout(10000), slow(5000))
|
@suite(timeout(10000), slow(5000))
|
||||||
export class TranslationSpecInplace {
|
export class TranslationSpecInplace {
|
||||||
@test
|
@test
|
||||||
@@ -226,8 +226,13 @@ export class TranslationSpecInplace {
|
|||||||
|
|
||||||
@test
|
@test
|
||||||
public nestedMetaArrayOfStringSubscriptUndefined() {
|
public nestedMetaArrayOfStringSubscriptUndefined() {
|
||||||
expect(translator.translate(dish).offers[0].inPlace.categories[1234]('printer')).to.equal('printer');
|
// tslint:disable-next-line: no-eval
|
||||||
expect(translator.translate(dish).offers[0].inPlace.categories[1]('printer')).to.not.equal('printer');
|
const workingTranslation = eval('translator.translate(dish).offers[0].inPlace.categories[1](\'printer\');');
|
||||||
|
// tslint:disable-next-line: no-eval
|
||||||
|
const defaultValueTranslation = eval('translator.translate(dish).offers[0].inPlace.categories[1234](\'printer\');');
|
||||||
|
|
||||||
|
expect(defaultValueTranslation).to.equal('printer');
|
||||||
|
expect(workingTranslation).to.not.equal('printer');
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
@@ -256,20 +261,30 @@ export class MetaTranslationSpec {
|
|||||||
|
|
||||||
@test
|
@test
|
||||||
public consistencyWithMetaClass() {
|
public consistencyWithMetaClass() {
|
||||||
const dishMetaTranslationsDE = translator.translatedPropertyNames(dish);
|
const dishMetaTranslationsDE = translator.translatedPropertyNames(dish.type);
|
||||||
const dishMetaTranslationsEN = translator.translatedPropertyNames(dish, 'en');
|
const dishMetaTranslationsEN = translator.translatedPropertyNames(dish.type, 'en');
|
||||||
expect(dishMetaTranslationsEN).to.not.deep.equal(dishMetaTranslationsDE);
|
expect(dishMetaTranslationsEN).to.not.deep.equal(dishMetaTranslationsDE);
|
||||||
expect(dishMetaTranslationsDE).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.de);
|
expect(dishMetaTranslationsDE).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.de);
|
||||||
expect(dishMetaTranslationsEN).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.en);
|
expect(dishMetaTranslationsEN).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.en);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test
|
||||||
|
public retrieveTranslatedThingType() {
|
||||||
|
const dishTypeDE = translator.translatedThingType(dish.type);
|
||||||
|
const dishTypeEN = translator.translatedThingType(dish.type, 'en');
|
||||||
|
const dishTypeBASE = translatorWithFallback.translatedThingType(dish.type);
|
||||||
|
expect(dishTypeDE).to.deep.equal(SCDishMeta.getInstance().fieldValueTranslations.de.type);
|
||||||
|
expect(dishTypeEN).to.deep.equal(SCDishMeta.getInstance().fieldValueTranslations.en.type);
|
||||||
|
expect(dishTypeBASE).to.deep.equal(SCDishMeta.getInstance().fieldValueTranslations.en.type);
|
||||||
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
public thingWithoutMetaClass() {
|
public thingWithoutMetaClass() {
|
||||||
const dishCopy = clone(dish);
|
const dishCopy = clone(dish);
|
||||||
const typeNonExistant = eval("(x) => x + 'typeNonExistant';");
|
const typeNonExistant = eval("(x) => x + 'typeNonExistant';");
|
||||||
// this will assign a non existant SCThingType to dishCopy
|
// this will assign a non existant SCThingType to dishCopy
|
||||||
dishCopy.type = typeNonExistant();
|
dishCopy.type = typeNonExistant();
|
||||||
const dishMetaTranslationsDE = translator.translatedPropertyNames(dishCopy);
|
const dishMetaTranslationsDE = translator.translatedPropertyNames(dishCopy.type);
|
||||||
expect(dishMetaTranslationsDE).to.be.undefined;
|
expect(dishMetaTranslationsDE).to.be.undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user