Skip to content

Commit c66192b

Browse files
committed
fix tests
1 parent f20a4f7 commit c66192b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ describe('Unit', function () {
6868
})
6969

7070
it('should create ampere-hour correctly', function () {
71-
const unit1 = new Unit(1.4, 'Ah')
72-
assert.strictEqual(unit1.value, 1.4)
71+
const n = 1.4
72+
const unit1 = new Unit(n, 'Ah')
73+
assert.strictEqual(unit1.value, n * 3600)
7374
assert.strictEqual(unit1.units[0].unit.name, 'Ah')
7475
})
7576

@@ -1076,6 +1077,16 @@ describe('Unit', function () {
10761077
assert.strictEqual(unit1.pow(2).skipAutomaticSimplification, false)
10771078
})
10781079

1080+
it('should be able to combine A and h into Ah', function () {
1081+
const n1 = 2
1082+
const n2 = 3
1083+
const unit1 = new Unit(n1, 'A')
1084+
const unit2 = new Unit(n2, 'h')
1085+
const unitM = unit1.multiply(unit2).simplify()
1086+
assert.strictEqual(unitM.units[0].unit.name, 'Ah')
1087+
assert.strictEqual(unitM.value, n1 * n2 * 3600)
1088+
})
1089+
10791090
it('should retain the units of their operands without simplifying', function () {
10801091
const unit1 = new Unit(10, 'N/s')
10811092
const unit2 = new Unit(10, 'h')

0 commit comments

Comments
 (0)