-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIs.spec.ts
More file actions
23 lines (22 loc) · 778 Bytes
/
Is.spec.ts
File metadata and controls
23 lines (22 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { selectively } from "./index"
describe("is", () => {
it("simple", () => expect(selectively.is({ class: "test" }, { id: "axb", class: "test" })).toBeTruthy())
it("not", () => expect(selectively.is({ class: "test" }, { id: "axb", class: "test2" })).toBeFalsy())
it("deep", () =>
expect(
selectively.is({ class: { name: "test" } }, { id: "axb", class: { name: "test", type: "type" } })
).toBeTruthy())
it("boolean", () => {
const expression = selectively.parse("happy: true")
console.log(expression.is({ happy: true }))
})
})
describe("filter", () => {
it("simple.filter", () =>
expect(
selectively.filter({ class: "test" }, [
{ id: "axb", class: "test" },
{ id: "axc", class: "test2" },
])
).toEqual([{ id: "axb", class: "test" }]))
})