initialValue arg
This commit is contained in:
parent
c4c916b1d2
commit
794d32d7d1
2 changed files with 11 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ module.exports = function($window) {
|
||||||
|
|
||||||
function xhr(args) {
|
function xhr(args) {
|
||||||
var stream = Stream.stream()
|
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"
|
var useBody = typeof args.useBody === "boolean" ? args.useBody : args.method !== "GET" && args.method !== "TRACE"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -241,6 +241,16 @@ o.spec("xhr", function() {
|
||||||
o(typeof xhr.send).equals("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.spec("failure", function() {
|
||||||
o("rejects on server error", function(done) {
|
o("rejects on server error", function(done) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue