Files
bun.sh/test/js/bun/css/util.ts
Zack Radisic 274e5a2022 CSS Parser (#14122)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-09-26 13:39:26 -07:00

52 lines
1.4 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import { cssInternals } from "bun:internal-for-testing";
import dedent from "./dedent";
const { minifyTestWithOptions, testWithOptions, prefixTestWithOptions, attrTest: __attrTest } = cssInternals;
type Browsers = {
android?: number;
chrome?: number;
edge?: number;
firefox?: number;
ie?: number;
ios_saf?: number;
opera?: number;
safari?: number;
samsung?: number;
};
export function minify_test(source: string, expected: string) {
return minifyTest(source, expected);
}
export function minifyTest(source: string, expected: string) {
test(source, () => {
expect(minifyTestWithOptions(source, expected)).toEqual(expected);
});
}
export function prefix_test(source: string, expected: string, targets: Browsers) {
test(source, () => {
expect(prefixTestWithOptions(source, expected, targets)).toEqual(expected);
});
}
export function css_test(source: string, expected: string) {
return cssTest(source, expected);
}
export function cssTest(source: string, expected: string) {
test(source, () => {
expect(testWithOptions(source, expected)).toEqual(expected);
});
}
export function attrTest(source: string, expected: string, minify: boolean, targets?: Browsers) {
return __attrTest(source, expected, minify, targets);
}
//
export function indoc(...args: any) {
return dedent(...args);
}
export { minifyTestWithOptions };