forked from N00ts/vue3-treeview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
useTree.spec.ts
47 lines (36 loc) · 1.09 KB
/
useTree.spec.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
import { reactive, isRef } from 'vue';
import useTree from "../../src/setup/useTree";
describe("test useTree", () => {
let useTest = null;
let props = null;
const fakeEmit = (evt: string, ...args: any[]) => {};
const v = require("vue");
v.onUnmounted = jest.fn();
const spy = jest.spyOn(v, "provide").mockImplementation(() => () => {});
beforeEach(() => {
props = reactive({
config: {
root: ["id1"]
},
nodes: {
id1: {
text: "test"
}
}
});
useTest = useTree(props, fakeEmit);
});
it("Expect to call provide", () => {
expect(spy).toBeCalledWith("emitter", fakeEmit);
});
it("Expect to create element ref", () => {
expect(isRef(useTest.element)).toBeTruthy();
expect(useTest.element.value).toBeNull();
});
it("Expect to have basic style", () => {
expect(useTest.style.value).toMatchObject({
"align-items": "center",
"display": "flex"
});
});
});