Skip to content

Commit 92f9b33

Browse files
authored
fix(energy): fix best array order (#691)
1 parent 6f25471 commit 92f9b33

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/conversions/measures/energy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { type Measure, MeasureKind } from '../types';
44

55
export const energy: Measure = {
66
kind: MeasureKind.Energy,
7-
best: ['GWh', 'MWh', 'kWh', 'Wh', 'J'],
7+
best: ['J', 'Wh', 'kWh', 'MWh', 'GWh'],
88
units: [
99
{ names: ['joule', 'joules'], symbols: ['J'], ratio: 1 },
1010
...expandMacro(Macros.si, {
+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
import { describe } from 'vitest';
1+
import { describe, expect } from 'vitest';
22
import { assertConversions } from '../../../test/assert-conversion';
3+
import { convert } from '../convert';
34

45
describe('conversions', () => {
56
assertConversions([{ from: [1, 'kWh'], to: [60 * 60 * 1000, 'joules'] }]);
67
assertConversions([{ from: [1000, 'J'], to: [1, 'kilojoule'] }]);
8+
assertConversions([{ from: [1000000, 'kWh'], to: [1, 'GWh'] }]);
9+
10+
const best1GWh = convert(1000000, 'kWh').to('best').toString();
11+
const best1Wh = convert(3600, 'J').to('best').toString();
12+
13+
expect(best1GWh).toBe('1 GWh');
14+
expect(best1Wh).toBe('1 Wh');
715
});

0 commit comments

Comments
 (0)