Skip to content

Commit c07d9e6

Browse files
committed
add a Wh test
1 parent c66192b commit c07d9e6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/unit-tests/type/unit/Unit.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,7 @@ describe('Unit', function () {
10781078
})
10791079

10801080
it('should be able to combine A and h into Ah', function () {
1081+
// by default, this stays Ah, due to the default unit system
10811082
const n1 = 2
10821083
const n2 = 3
10831084
const unit1 = new Unit(n1, 'A')
@@ -1087,6 +1088,17 @@ describe('Unit', function () {
10871088
assert.strictEqual(unitM.value, n1 * n2 * 3600)
10881089
})
10891090

1091+
it('should be able to combine W and h into Wh', function () {
1092+
// by default, this converts to J, due to the default unit system
1093+
const n1 = 2
1094+
const n2 = 3
1095+
const unit1 = new Unit(n1, 'W')
1096+
const unit2 = new Unit(n2, 'h')
1097+
const unitM = unit1.multiply(unit2).to('Wh')
1098+
assert.strictEqual(unitM.units[0].unit.name, 'Wh')
1099+
assert.strictEqual(unitM.value, n1 * n2 * 3600)
1100+
})
1101+
10901102
it('should retain the units of their operands without simplifying', function () {
10911103
const unit1 = new Unit(10, 'N/s')
10921104
const unit2 = new Unit(10, 'h')

0 commit comments

Comments
 (0)