More tests

This commit is contained in:
Pieter Vander Vennet 2022-03-15 01:53:08 +01:00
parent 82e59bc1eb
commit 50d383279d
5 changed files with 76 additions and 86 deletions

View file

@ -60,7 +60,27 @@ export class Denomination {
)
}
public canonicalValue(value: string, actAsDefault?: boolean) {
/**
* Create a representation of the given value
* @param value: the value from OSM
* @param actAsDefault: if set and the value can be parsed as number, will be parsed and trimmed
*
* const unit = new Denomination({
* canonicalDenomination: "m",
* alternativeDenomination: ["meter"],
* 'default': true,
* human: {
* en: "meter"
* }
* }, "test")
* unit.canonicalValue("42m") // =>"42 m"
* unit.canonicalValue("42") // =>"42 m"
* unit.canonicalValue("42 m") // =>"42 m"
* unit.canonicalValue("42 meter") // =>"42 m"
*
*
*/
public canonicalValue(value: string, actAsDefault?: boolean) : string {
if (value === undefined) {
return undefined;
}