methods.spec.js 512 B

123456789101112131415161718192021222324252627
  1. import Vue from 'vue'
  2. describe('Options methods', () => {
  3. it('should have correct context', () => {
  4. const vm = new Vue({
  5. data: {
  6. a: 1
  7. },
  8. methods: {
  9. plus () {
  10. this.a++
  11. }
  12. }
  13. })
  14. vm.plus()
  15. expect(vm.a).toBe(2)
  16. })
  17. it('should warn undefined methods', () => {
  18. new Vue({
  19. methods: {
  20. hello: undefined
  21. }
  22. })
  23. expect(`method "hello" has an undefined value in the component definition`).toHaveBeenWarned()
  24. })
  25. })