methods.spec.js 610 B

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