Skip to content

Commit

Permalink
Enable the tests for the updated MithrilJS#1595, add an additional sa…
Browse files Browse the repository at this point in the history
…nity check
  • Loading branch information
pygy committed May 29, 2017
1 parent 29bc42b commit d21bfd4
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions render/tests/test-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,20 @@ o.spec("attributes", function() {
o("'' and 0 are different values", function() {
var a = {tag: "input", attrs: {value: 0}, children:[{tag:"#", children:""}]}
var b = {tag: "input", attrs: {value: ""}, children:[{tag:"#", children:""}]}
var c = {tag: "input", attrs: {value: 0}, children:[{tag:"#", children:""}]}

render(root, [a]);

o(a.dom.value).equals("0")

render(root, [b]);

o(a.dom.value).equals("")
o(b.dom.value).equals("")

// #1959 redux
// TODO: UNCOMMENT
// render(root, [a]);
// #1595 redux
render(root, [c]);

// o(a.dom.value).equals("0")
o(c.dom.value).equals("0")
})
o("isn't set when equivalent to the previous value and focused", function() {
var $window = domMock({spy: o.spy})
Expand Down Expand Up @@ -362,6 +362,7 @@ o.spec("attributes", function() {
o("'' and 0 are different values", function() {
var a = {tag: "option", attrs: {value: 0}, children:[{tag:"#", children:""}]}
var b = {tag: "option", attrs: {value: ""}, children:[{tag:"#", children:""}]}
var c = {tag: "option", attrs: {value: 0}, children:[{tag:"#", children:""}]}

render(root, [a]);

Expand All @@ -371,11 +372,10 @@ o.spec("attributes", function() {

o(a.dom.value).equals("")

// #1959 redux
// TODO: UNCOMMENT
// render(root, [a]);
// #1595 redux
render(root, [c]);

// o(a.dom.value).equals("0")
o(c.dom.value).equals("0")
})
o("isn't set when equivalent to the previous value", function() {
var $window = domMock({spy: o.spy})
Expand Down Expand Up @@ -469,18 +469,38 @@ o.spec("attributes", function() {
})
o("'' and 0 are different values when focused", function() {
var a = makeSelect("")
// var b = makeSelect(0)
var b = makeSelect(0)

render(root, [a])
a.dom.focus()

o(a.dom.value).equals("")

// #1959 redux
// TODO: UNCOMMENT
// render(root, [b])
// #1595 redux
render(root, [b])

o(b.dom.value).equals("0")
})
o("'' and null are different values when focused", function() {
var a = makeSelect("")
var b = makeSelect(null)
var c = makeSelect("")

render(root, [a])
a.dom.focus()

o(a.dom.value).equals("")
o(a.dom.selectedIndex).equals(4)

render(root, [b])

// o(b.dom.value).equals("0")
o(b.dom.value).equals("")
o(b.dom.selectedIndex).equals(-1)

render(root, [c])

o(c.dom.value).equals("")
o(c.dom.selectedIndex).equals(4)
})
o("updates with the same value do not re-set the attribute if the select has focus", function() {
var $window = domMock({spy: o.spy})
Expand Down

0 comments on commit d21bfd4

Please sign in to comment.