Browse Source

Test priorities.

Prevent error like #2573 from happening again.
zigomir 10 years ago
parent
commit
bfe0184fd0
1 changed files with 22 additions and 0 deletions
  1. 22 0
      test/unit/specs/directives/public/for/for_spec.js

+ 22 - 0
test/unit/specs/directives/public/for/for_spec.js

@@ -107,6 +107,28 @@ describe('v-for', function () {
     expect(el.innerHTML).toBe('<div>aaa a</div><div>bbb b</div>')
   })
 
+  it('check priorities: v-if before v-for', function () {
+    new Vue({
+      el: el,
+      data: {
+        items: [1, 2, 3]
+      },
+      template: '<div v-if="item < 3" v-for="item in items">{{item}}</div>'
+    })
+    expect(el.textContent).toBe('12')
+  })
+
+  it('check priorities: v-if after v-for', function () {
+    new Vue({
+      el: el,
+      data: {
+        items: [1, 2, 3]
+      },
+      template: '<div v-for="item in items" v-if="item < 3">{{item}}</div>'
+    })
+    expect(el.textContent).toBe('12')
+  })
+
   it('component', function (done) {
     var vm = new Vue({
       el: el,