vue-test.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import Vue = require("../index");
  2. class Test extends Vue {
  3. testProperties() {
  4. this.$data;
  5. this.$el;
  6. this.$options;
  7. this.$parent;
  8. this.$root;
  9. this.$children;
  10. this.$refs;
  11. this.$slots;
  12. this.$isServer;
  13. }
  14. // test property reification
  15. $refs: {
  16. vue: Vue,
  17. element: HTMLInputElement,
  18. vues: Vue[],
  19. elements: HTMLInputElement[]
  20. }
  21. testReification() {
  22. this.$refs.vue.$data;
  23. this.$refs.element.value;
  24. this.$refs.vues[0].$data;
  25. this.$refs.elements[0].value;
  26. }
  27. testMethods() {
  28. this.$mount("#app", false);
  29. this.$forceUpdate();
  30. this.$destroy();
  31. this.$set({}, "key", "value");
  32. this.$delete({}, "key");
  33. this.$watch("a", (val: number, oldVal: number) => {}, {
  34. immediate: true,
  35. deep: false
  36. })();
  37. this.$watch(() => {}, (val: number) => {});
  38. this.$on("", () => {});
  39. this.$once("", () => {});
  40. this.$off("", () => {});
  41. this.$emit("", 1, 2, 3);
  42. this.$nextTick(function() {
  43. this.$nextTick;
  44. });
  45. this.$createElement("div", {}, "message");
  46. }
  47. static testConfig() {
  48. const { config } = this;
  49. config.silent;
  50. config.optionMergeStrategies;
  51. config.devtools;
  52. config.errorHandler = (err, vm) => {
  53. if (vm instanceof Test) {
  54. vm.testProperties();
  55. vm.testMethods();
  56. }
  57. };
  58. config.keyCodes = { esc: 27 };
  59. }
  60. static testMethods() {
  61. this.extend({
  62. data() {
  63. return {
  64. msg: ""
  65. };
  66. }
  67. });
  68. this.nextTick(() => {});
  69. this.set({}, "", "");
  70. this.set([true, false, true], 1, true);
  71. this.delete({}, "");
  72. this.directive("", {bind() {}});
  73. this.filter("", (value: number) => value);
  74. this.component("", { data: () => ({}) });
  75. this.component("", { functional: true });
  76. this.use;
  77. this.mixin(Test);
  78. this.compile("<div>{{ message }}</div>");
  79. }
  80. }