forked from vuejs/vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue-test.ts
97 lines (91 loc) · 2.15 KB
/
vue-test.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import Vue = require("../index");
class Test extends Vue {
a: number;
testProperties() {
this.$data;
this.$el;
this.$options;
this.$parent;
this.$root;
this.$children;
this.$refs;
this.$slots;
this.$isServer;
this.$ssrContext;
}
// test property reification
$refs: {
vue: Vue,
element: HTMLInputElement,
vues: Vue[],
elements: HTMLInputElement[]
}
testReification() {
this.$refs.vue.$data;
this.$refs.element.value;
this.$refs.vues[0].$data;
this.$refs.elements[0].value;
}
testMethods() {
this.$mount("#app", false);
this.$forceUpdate();
this.$destroy();
this.$set({}, "key", "value");
this.$delete({}, "key");
this.$watch("a", (val: number, oldVal: number) => {}, {
immediate: true,
deep: false
})();
this.$watch(() => this.a, (val: number) => {});
this.$on("", () => {});
this.$once("", () => {});
this.$off("", () => {});
this.$emit("", 1, 2, 3);
this.$nextTick(function() {
this.$nextTick;
});
this.$nextTick().then(() => {});
this.$createElement("div", {}, "message");
}
static testConfig() {
const { config } = this;
config.silent;
config.optionMergeStrategies;
config.devtools;
config.errorHandler = (err, vm) => {
if (vm instanceof Test) {
vm.testProperties();
vm.testMethods();
}
};
config.warnHandler = (msg, vm) => {
if (vm instanceof Test) {
vm.testProperties();
vm.testMethods();
}
};
config.keyCodes = { esc: 27 };
}
static testMethods() {
this.extend({
data() {
return {
msg: ""
};
}
});
this.nextTick(() => {});
this.nextTick().then(() => {});
this.set({}, "", "");
this.set([true, false, true], 1, true);
this.delete({}, "");
this.delete([true, false], 0);
this.directive("", {bind() {}});
this.filter("", (value: number) => value);
this.component("", { data: () => ({}) });
this.component("", { functional: true, render () {}});
this.use;
this.mixin(Test);
this.compile("<div>{{ message }}</div>");
}
}