Repository: vuejs/vue
Pull request: Improve looseequal test case

Related to PR #4528  . Add boolean type test case

Changed files:
filename: test/unit/features/directives/model-checkbox.spec.js
patch: @@ -169,27 +169,51 @@ describe('Directive v-model checkbox', () => {
           '<input type="checkbox" value="" v-model="test">' +
           '<input type="checkbox" value="0" v-model="test">' +
           '<input type="checkbox" value="1" v-model="test">' +
+          '<input type="checkbox" value="false" v-model="test">' +
+          '<input type="checkbox" value="true" v-model="test">' +
         '</div>'
     }).$mount()
     var checkboxInput = vm.$el.children
     expect(checkboxInput[0].checked).toBe(false)
     expect(checkboxInput[1].checked).toBe(true)
     expect(checkboxInput[2].checked).toBe(false)
+    expect(checkboxInput[3].checked).toBe(false)
+    expect(checkboxInput[4].checked).toBe(false)
     vm.test = [1]
     waitForUpdate(() => {
       expect(checkboxInput[0].checked).toBe(false)
       expect(checkboxInput[1].checked).toBe(false)
       expect(checkboxInput[2].checked).toBe(true)
+      expect(checkboxInput[3].checked).toBe(false)
+      expect(checkboxInput[4].checked).toBe(false)
       vm.test = ['']
     }).then(() => {
       expect(checkboxInput[0].checked).toBe(true)
       expect(checkboxInput[1].checked).toBe(false)
       expect(checkboxInput[2].checked).toBe(false)
-      vm.test = ['', 0, 1]
+      expect(checkboxInput[3].checked).toBe(false)
+      expect(checkboxInput[4].checked).toBe(false)
+      vm.test = [false]
+    }).then(() => {
+      expect(checkboxInput[0].checked).toBe(false)
+      expect(checkboxInput[1].checked).toBe(false)
+      expect(checkboxInput[2].checked).toBe(false)
+      expect(checkboxInput[3].checked).toBe(true)
+      expect(checkboxInput[4].checked).toBe(false)
+      vm.test = [true]
+    }).then(() => {
+      expect(checkboxInput[0].checked).toBe(false)
+      expect(checkboxInput[1].checked).toBe(false)
+      expect(checkboxInput[2].checked).toBe(false)
+      expect(checkboxInput[3].checked).toBe(false)
+      expect(checkboxInput[4].checked).toBe(true)
+      vm.test = ['', 0, 1, false, true]
     }).then(() => {
       expect(checkboxInput[0].checked).toBe(true)
       expect(checkboxInput[1].checked).toBe(true)
       expect(checkboxInput[2].checked).toBe(true)
+      expect(checkboxInput[3].checked).toBe(true)
+      expect(checkboxInput[4].checked).toBe(true)
     }).then(done)
   })
 

filename: test/unit/features/directives/model-radio.spec.js
patch: @@ -156,22 +156,44 @@ describe('Directive v-model radio', () => {
           '<input type="radio" value="" v-model="test" name="test">' +
           '<input type="radio" value="0" v-model="test" name="test">' +
           '<input type="radio" value="1" v-model="test" name="test">' +
+          '<input type="radio" value="false" v-model="test" name="test">' +
+          '<input type="radio" value="true" v-model="test" name="test">' +
         '</div>'
     }).$mount()
     var radioboxInput = vm.$el.children
     expect(radioboxInput[0].checked).toBe(false)
     expect(radioboxInput[1].checked).toBe(false)
     expect(radioboxInput[2].checked).toBe(true)
+    expect(radioboxInput[3].checked).toBe(false)
+    expect(radioboxInput[4].checked).toBe(false)
     vm.test = 0
     waitForUpdate(() => {
       expect(radioboxInput[0].checked).toBe(false)
       expect(radioboxInput[1].checked).toBe(true)
       expect(radioboxInput[2].checked).toBe(false)
+      expect(radioboxInput[3].checked).toBe(false)
+      expect(radioboxInput[4].checked).toBe(false)
       vm.test = ''
     }).then(() => {
       expect(radioboxInput[0].checked).toBe(true)
       expect(radioboxInput[1].checked).toBe(false)
       expect(radioboxInput[2].checked).toBe(false)
+      expect(radioboxInput[3].checked).toBe(false)
+      expect(radioboxInput[4].checked).toBe(false)
+      vm.test = false
+    }).then(() => {
+      expect(radioboxInput[0].checked).toBe(false)
+      expect(radioboxInput[1].checked).toBe(false)
+      expect(radioboxInput[2].checked).toBe(false)
+      expect(radioboxInput[3].checked).toBe(true)
+      expect(radioboxInput[4].checked).toBe(false)
+      vm.test = true
+    }).then(() => {
+      expect(radioboxInput[0].checked).toBe(false)
+      expect(radioboxInput[1].checked).toBe(false)
+      expect(radioboxInput[2].checked).toBe(false)
+      expect(radioboxInput[3].checked).toBe(false)
+      expect(radioboxInput[4].checked).toBe(true)
     }).then(done)
   })
 

filename: test/unit/features/directives/model-select.spec.js
patch: @@ -329,22 +329,44 @@ describe('Directive v-model select', () => {
           '<option value="">a</option>' +
           '<option value="0">b</option>' +
           '<option value="1">c</option>' +
+          '<option value="false">c</option>' +
+          '<option value="true">c</option>' +
         '</select>'
     }).$mount()
     var opts = vm.$el.options
     expect(opts[0].selected).toBe(false)
     expect(opts[1].selected).toBe(true)
     expect(opts[2].selected).toBe(false)
+    expect(opts[3].selected).toBe(false)
+    expect(opts[4].selected).toBe(false)
     vm.test = 1
     waitForUpdate(() => {
       expect(opts[0].selected).toBe(false)
       expect(opts[1].selected).toBe(false)
       expect(opts[2].selected).toBe(true)
+      expect(opts[3].selected).toBe(false)
+      expect(opts[4].selected).toBe(false)
       vm.test = ''
     }).then(() => {
       expect(opts[0].selected).toBe(true)
       expect(opts[1].selected).toBe(false)
       expect(opts[2].selected).toBe(false)
+      expect(opts[3].selected).toBe(false)
+      expect(opts[4].selected).toBe(false)
+      vm.test = false
+    }).then(() => {
+      expect(opts[0].selected).toBe(false)
+      expect(opts[1].selected).toBe(false)
+      expect(opts[2].selected).toBe(false)
+      expect(opts[3].selected).toBe(true)
+      expect(opts[4].selected).toBe(false)
+      vm.test = true
+    }).then(() => {
+      expect(opts[0].selected).toBe(false)
+      expect(opts[1].selected).toBe(false)
+      expect(opts[2].selected).toBe(false)
+      expect(opts[3].selected).toBe(false)
+      expect(opts[4].selected).toBe(true)
     }).then(done)
   })