-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathcss-theme.test.ts
More file actions
47 lines (44 loc) · 1.71 KB
/
css-theme.test.ts
File metadata and controls
47 lines (44 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
import { describe } from 'bun:test';
import type { Font } from '@onlook/models';
import { addFontToCssTheme, removeFontFromCssTheme } from '../src/helpers/css-theme';
import { runDataDrivenTests } from './test-utils';
import path from 'path';
const __dirname = import.meta.dir;
describe('addFontToCssTheme', () => {
runDataDrivenTests(
{
casesDir: path.resolve(__dirname, 'data/css-theme/add-font-to-css-theme'),
inputFileName: 'config',
expectedFileName: 'expected',
},
async (input: { font: Font; content: string }) => {
return addFontToCssTheme(input.font, input.content);
},
async (content: string, filePath?: string) => {
const config = JSON.parse(content);
const inputContent = await Bun.file(
path.resolve(path.dirname(filePath || ''), 'input.css'),
).text();
return { font: config.font, content: inputContent };
},
);
});
describe('removeFontFromCssTheme', () => {
runDataDrivenTests(
{
casesDir: path.resolve(__dirname, 'data/css-theme/remove-font-from-css-theme'),
inputFileName: 'config',
expectedFileName: 'expected',
},
async (input: { fontId: string; content: string }) => {
return removeFontFromCssTheme(input.fontId, input.content);
},
async (content: string, filePath?: string) => {
const config = JSON.parse(content);
const inputContent = await Bun.file(
path.resolve(path.dirname(filePath || ''), 'input.css'),
).text();
return { fontId: config.fontId, content: inputContent };
},
);
});