propsData.spec.js 656 B

123456789101112131415161718192021222324252627282930
  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('option "propsData" can only be used during instance creation').toHaveBeenWarned()
  27. })
  28. })