mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2026-08-08 02:02:33 +00:00
Theme Builder: structured color/type controls, scheme catalog, diverging preview
This commit is contained in:
@@ -88,4 +88,20 @@ describe('THEME_PREVIEW_SPECS', () => {
|
||||
const ids = THEME_PREVIEW_SPECS.map((c) => c.id);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
});
|
||||
|
||||
it('exercises every color family the builder controls', () => {
|
||||
type ColorDef = { type?: string; scale?: { domainMid?: unknown } };
|
||||
const colorOf = (spec: (typeof THEME_PREVIEW_SPECS)[number]['spec']): ColorDef | undefined =>
|
||||
(spec.encoding as { color?: ColorDef } | undefined)?.color;
|
||||
|
||||
const colors = THEME_PREVIEW_SPECS.map((c) => colorOf(c.spec));
|
||||
// mark.color (a card with no color encoding), categorical, sequential
|
||||
// (quantitative, no midpoint), and diverging (quantitative with a midpoint).
|
||||
expect(colors.some((c) => c === undefined)).toBe(true);
|
||||
expect(colors.some((c) => c?.type === 'nominal')).toBe(true);
|
||||
expect(colors.some((c) => c?.type === 'quantitative' && c.scale?.domainMid === undefined)).toBe(
|
||||
true,
|
||||
);
|
||||
expect(colors.some((c) => c?.scale?.domainMid !== undefined)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user