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

@ -0,0 +1,30 @@
import {describe} from 'mocha'
import {expect} from 'chai'
import {Unit} from "../../Models/Unit";
import {Denomination} from "../../Models/Denomination";
describe("Unit", () => {
it("should convert a value back and forth", () => {
const unit = new Denomination({
"canonicalDenomination": "MW",
"alternativeDenomination": ["megawatts", "megawatt"],
"human": {
"en": " megawatts",
"nl": " megawatt"
},
"default": true
}, "test");
const canonical = unit.canonicalValue("5")
expect(canonical).eq( "5 MW")
const units = new Unit(["key"], [unit], false)
const [detected, detectedDenom] = units.findDenomination("5 MW")
expect(detected).eq( "5")
expect(detectedDenom).eq( unit)
}
)
})