-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev_deps.ts
66 lines (60 loc) · 1.43 KB
/
dev_deps.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
export {
any,
anyArray,
anyBoolean,
anyFunction,
anyNumber,
anyOf,
anyString,
objectContaining,
test,
} from "https://deno.land/x/[email protected]/mod.ts";
import {
defineExpect,
equal,
jestExtendedMatcherMap,
jestMatcherMap,
jestModifierMap,
MatchResult,
} from "https://deno.land/x/[email protected]/mod.ts";
import { isObject } from "https://deno.land/x/[email protected]/mod.ts";
import {
toAST,
toObject,
} from "https://deno.land/x/[email protected]/mod.ts";
export { toAST };
import { default as Root } from "https://deno.land/x/[email protected]/lib/root.js";
import type { CSS } from "./core/types.ts";
function toEqualJSCSS(
actual: unknown,
expect: CSS,
): MatchResult {
if (!(actual instanceof Root) && !isObject(actual)) {
return {
pass: false,
expected: "Expected should be Root or JSCSS Object:",
};
}
const root = actual instanceof Root
? actual
: toAST(actual as Record<any, any>);
const actualJSCSS = toObject(root);
const expected = toObject(toAST(expect));
return {
pass: equal(actualJSCSS, expected),
expected,
resultActual: actualJSCSS,
};
}
export const expect = defineExpect({
matcherMap: {
...jestMatcherMap,
...jestExtendedMatcherMap,
toEqualJSCSS,
},
modifierMap: jestModifierMap,
});
export type ParamReturn<T extends (...args: any[]) => unknown> = [
...Parameters<T>,
ReturnType<T>,
];