initialValue arg

This commit is contained in:
Leo Horie 2016-06-24 15:58:30 -04:00
parent c4c916b1d2
commit 794d32d7d1
2 changed files with 11 additions and 0 deletions

View file

@ -11,6 +11,7 @@ module.exports = function($window) {
function xhr(args) {
var stream = Stream.stream()
if (args.initialValue !== undefined) stream(args.initialValue)
var useBody = typeof args.useBody === "boolean" ? args.useBody : args.method !== "GET" && args.method !== "TRACE"

View file

@ -241,6 +241,16 @@ o.spec("xhr", function() {
o(typeof xhr.send).equals("function")
}
})
o("initialValue parameter works", function() {
mock.$defineRoutes({
"GET /items": function() {
return {status: 200, responseText: JSON.stringify([{a: 1}])}
}
})
var items = xhr({method: "GET", url: "/items", initialValue: []})
o(items()).deepEquals([])
})
})
o.spec("failure", function() {
o("rejects on server error", function(done) {