vue-test.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. testMethods() {
  15. this.$mount("#app", false);
  16. this.$forceUpdate();
  17. this.$destroy();
  18. this.$set({}, "key", "value");
  19. this.$delete({}, "key");
  20. this.$watch("a", (val: number, oldVal: number) => {}, {
  21. immediate: true,
  22. deep: false
  23. })();
  24. this.$watch(() => {}, (val: number) => {});
  25. this.$on("", () => {});
  26. this.$once("", () => {});
  27. this.$off("", () => {});
  28. this.$emit("", 1, 2, 3);
  29. this.$nextTick(function() {
  30. this.$nextTick;
  31. });
  32. this.$createElement("div", {}, "message", "");
  33. }
  34. static testConfig() {
  35. const { config } = this;
  36. config.silent;
  37. config.optionMergeStrategies;
  38. config.devtools;
  39. config.errorHandler = (err, vm) => {
  40. if (vm instanceof Test) {
  41. vm.testProperties();
  42. vm.testMethods();
  43. }
  44. };
  45. config.keyCodes = { esc: 27 };
  46. }
  47. static testMethods() {
  48. this.extend({
  49. data() {
  50. return {
  51. msg: ""
  52. };
  53. }
  54. });
  55. this.nextTick(() => {});
  56. this.set({}, "", "");
  57. this.set([true, false, true], 1, true);
  58. this.delete({}, "");
  59. this.directive("", {bind() {}});
  60. this.filter("", (value: number) => value);
  61. this.component("", { data: () => ({}) });
  62. this.use;
  63. this.mixin(Test);
  64. this.compile("<div>{{ message }}</div>");
  65. }
  66. }