Fixed m.request initialValue tests

This commit is contained in:
Barney 2014-11-10 15:32:31 +00:00
parent 71a6321c46
commit b5de0c2b4d
3 changed files with 143 additions and 75 deletions

View file

@ -1688,11 +1688,14 @@ function testMithril(mock) {
return xhr.$headers["Content-Type"] === undefined
})
test(function() {
var prop = m.request({method: "POST", url: "test", default: "foo"})
return prop() === "foo"
var prop = m.request({method: "POST", url: "test", initialValue: "foo"})
var initialValue = prop();
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
return initialValue === "foo"
})
test(function() {
var prop = m.request({method: "POST", url: "test", default: "foo"}).then(function(value) {return "bar"})
var prop = m.request({method: "POST", url: "test", initialValue: "foo"}).then(function(value) {return "bar"})
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
return prop() === "bar"
})