forked from MapComplete/MapComplete
Rename tests to test; add a few tests
This commit is contained in:
parent
df706d2f97
commit
c3859d56c6
28 changed files with 33 additions and 5 deletions
30
test/Models/Units.spec.ts
Normal file
30
test/Models/Units.spec.ts
Normal 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)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue