Skip to content

Commit 8fc0a6f

Browse files
committed
Test: Add tests for conversions between hue-based color models
1 parent c115f3c commit 8fc0a6f

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

test/test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,37 @@ Object.entries(nameToType).forEach(
433433
)
434434
}
435435
)
436+
437+
// Test Suite #4
438+
// Hue-based conversions
439+
440+
const testColors4 =
441+
[
442+
[ new HSB(1, 0, 0)
443+
, new HSBA(1, 0, 0, 100)
444+
, new HSL(1, 0, 0)
445+
, new HSLA(1, 0, 0, 100)
446+
]
447+
]
448+
449+
const nameToTypeH =
450+
Object.fromEntries(
451+
Object.
452+
keys(nameToType).
453+
filter((n) => n.startsWith("HS")).
454+
map((n) => [n, nameToType[n]])
455+
)
456+
457+
Object.entries(nameToTypeH).forEach(
458+
([name1, typ1]) => {
459+
Object.entries(nameToTypeH).forEach(
460+
([name2, typ2]) => {
461+
pairsOf(testColors4)(typ1, typ2).forEach(([a, b]) => {
462+
test(`Hue: ${a.toString()} converts to ${name1 === name2 ? "itself" : b.toString()}`, () => {
463+
checkEquality(a, b)
464+
})
465+
})
466+
}
467+
)
468+
}
469+
)

0 commit comments

Comments
 (0)