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.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user