vue-test.ts 1.9 KB

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