Files
advanced-camera-card/tests/card-controller/style-manager.browser.test.ts
T
Dermot Duffy 80ec92e3b2 refactor: Replace Rollup with Vite (#2656)
This is a high risk change: every byte the card ships is emitted by a
different bundler, minified by a different minifier, and every
stylesheet is compiled by a different sass. The intent is that the
card's behaviour is unchanged.

**Significant development win**: Build time drops from 24s to 1.1s 🎉 

Also adds a test suite ('dist') that runs against the built bundle.
2026-08-04 15:00:13 -07:00

45 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { MountedCardFactory } from '../browser/mounted-card';
import {
createStillCameraHASS,
createStillImageCardConfig,
} from '../browser/test-utils';
// A colour the dark theme sets and the card carries no other way. Reading it
// back proves the stylesheet reached the card rather than merely compiling.
// See src/scss/themes/dark.scss .
const DARK_PRIMARY_BACKGROUND = '#111111';
const mountThemed = async (themes: string[]) =>
await MountedCardFactory.createFromSource(
createStillImageCardConfig({ view: { theme: { themes } } }),
createStillCameraHASS(),
);
describe('themes', () => {
it('should style the card from the theme it is configured with', async () => {
const card = await mountThemed(['dark']);
await card.waitForRender(
() => card.card.getAttribute('themes'),
'the card being given its themes',
);
expect(
getComputedStyle(card.card).getPropertyValue('--primary-background-color').trim(),
).toBe(DARK_PRIMARY_BACKGROUND);
});
it('should not style the card from a theme it is not configured with', async () => {
const card = await mountThemed(['light']);
await card.waitForRender(
() => card.card.getAttribute('themes'),
'the card being given its themes',
);
expect(
getComputedStyle(card.card).getPropertyValue('--primary-background-color').trim(),
).not.toBe(DARK_PRIMARY_BACKGROUND);
});
});