File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
test/unit-tests/type/unit Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff 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' )
You can’t perform that action at this time.
0 commit comments