-
Notifications
You must be signed in to change notification settings - Fork 279
Expand file tree
/
Copy pathinlinedCss.lite.ts
More file actions
47 lines (37 loc) · 1.71 KB
/
Copy pathinlinedCss.lite.ts
File metadata and controls
47 lines (37 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const getInlinedCss = () =>
Array.from(document.querySelectorAll('head > style'))
.map(el => el.textContent)
.join('');
export default () => {
describe('SCSS module CSS — Lite inlined styles', () => {
it('should have at least one non-empty <style> tag in the head', () => {
const styleEls = Array.from(document.querySelectorAll('head > style'));
const hasContent = styleEls.some(
el => el.textContent && el.textContent.trim() !== '',
);
expect(hasContent).toBe(true);
});
it('should inline CSS custom properties from the SCSS module palette (--brand-background)', () => {
expect(getInlinedCss()).toContain('--brand-background');
});
it('should inline CSS custom properties from the SCSS module font variants (--sans-regular-font-family)', () => {
expect(getInlinedCss()).toContain('--sans-regular-font-family');
});
it('should inline @font-face declarations from the SCSS module font faces', () => {
const css = getInlinedCss();
expect(css).toContain('@font-face');
expect(css).toContain('font-family:ReithSans');
});
it('should inline CSS module component rules (hashed class names)', () => {
const css = getInlinedCss();
// CSS module class names follow the pattern: ComponentName_localName__hash
// This confirms CSS module extraction is working, not just global SCSS
expect(css).toMatch(/\.[A-Za-z]+_[a-zA-Z]+__[A-Za-z0-9]+/);
});
it('should strip unnecessary vendor prefixes left in by Emotion', () => {
const css = getInlinedCss();
expect(css).not.toMatch(/-webkit-box-(align|pack)\s*:/);
expect(css).not.toMatch(/-ms-flex-(align|pack|direction|wrap)\s*:/);
});
});
};