propsData.spec.ts 668 B

1234567891011121314151617181920212223242526272829303132
  1. import Vue from 'vue'
  2. describe('Options propsData', () => {
  3. it('should work', done => {
  4. const A = Vue.extend({
  5. props: ['a'],
  6. template: '<div>{{ a }}</div>'
  7. })
  8. const vm = new A({
  9. propsData: {
  10. a: 123
  11. }
  12. }).$mount()
  13. expect(vm.a).toBe(123)
  14. expect(vm.$el.textContent).toBe('123')
  15. vm.a = 234
  16. waitForUpdate(() => {
  17. expect(vm.$el.textContent).toBe('234')
  18. }).then(done)
  19. })
  20. it('warn non instantiation usage', () => {
  21. Vue.extend({
  22. propsData: {
  23. a: 123
  24. }
  25. })
  26. expect(
  27. 'option "propsData" can only be used during instance creation'
  28. ).toHaveBeenWarned()
  29. })
  30. })