Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 9e580b2

Browse files
committed
test(~compiler.test.ts*): add compiler unit tests
1 parent 3e59708 commit 9e580b2

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

test/sheet-compiler.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { genBase62Hash, sheetCompiler } from '../src/_internal';
2+
import { max_lg } from '../src/core';
3+
4+
test('sheetCompiler produces expected output', async () => {
5+
const object = {
6+
e2e: {
7+
color: 'pink',
8+
[max_lg]: {
9+
color: 'aqua',
10+
},
11+
},
12+
};
13+
14+
const base62Hash = genBase62Hash(object, 5);
15+
const { styleSheet } = sheetCompiler(object, base62Hash);
16+
17+
expect(styleSheet).toContain('.e2e_');
18+
expect(styleSheet).toContain('color: pink;');
19+
expect(styleSheet).toContain('@media (max-width: 1024px)');
20+
expect(styleSheet).toContain('color: aqua;');
21+
});

test/style-compiler.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { genBase62Hash, styleCompiler } from '../src/_internal';
2+
import { max_lg } from '../src/core';
3+
4+
test('styleCompiler produces expected output', async () => {
5+
const object = {
6+
color: 'blue',
7+
margin: '10px',
8+
[max_lg]: {
9+
color: 'aqua',
10+
margin: '24px',
11+
},
12+
};
13+
14+
const base62Hash = genBase62Hash(object, 5);
15+
const { styleSheet } = styleCompiler(object, base62Hash);
16+
17+
expect(styleSheet).toContain('color: blue;');
18+
expect(styleSheet).toContain('margin: 10px');
19+
expect(styleSheet).toContain('@media (max-width: 1024px)');
20+
expect(styleSheet).toContain('color: aqua;');
21+
expect(styleSheet).toContain('margin: 24px');
22+
});

0 commit comments

Comments
 (0)