Rename tests to test; add a few tests

This commit is contained in:
Pieter Vander Vennet 2022-04-06 03:06:28 +02:00
parent df706d2f97
commit c3859d56c6
28 changed files with 33 additions and 5 deletions

30
test/Models/Units.spec.ts Normal file
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)
}
)
})