-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Extract watt/ftp test to an actual test
- Loading branch information
1 parent
41c3dae
commit e47c2d2
Showing
2 changed files
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { expect, test } from 'vitest'; | ||
import { ftpPercentFromWatt, wattFromFtpPercent } from './general'; | ||
|
||
test('Watt values passed through ftpPercentFromWatt and wattFromFtpPercent ends up with the entered Watt value', () => { | ||
let failures = []; | ||
for (let ftp = 200; ftp <= 500; ftp += 1) { | ||
for (let watt = 0; watt <= 1000; watt += 1) { | ||
const ftpPct = ftpPercentFromWatt(watt, ftp); | ||
const wattFromFtpPct = wattFromFtpPercent(ftpPct, ftp); | ||
if (wattFromFtpPct !== watt) { | ||
failures.push({ | ||
watt, | ||
exactWattFromFtpPct: (ftpPct * ftp) / 100, | ||
ftpPct, | ||
ftp, | ||
}); | ||
} | ||
} | ||
} | ||
expect(failures.length).toBe(0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters