Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0tdoAI1C: Added support for cancelling requests.
Inspired by (and somewhat copy-pasted from) #4
- Loading branch information
Joel W Kall
committed
Jan 16, 2019
1 parent
9d902d3
commit d7c0f1b
Showing
11 changed files
with
441 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
import autoCompleteResponse from "./mocks/autocomplete-response-ok"; | ||
import nock from "nock"; | ||
import chai, { | ||
assert, | ||
expect | ||
} from "chai"; | ||
import common from "./common"; | ||
|
||
module.exports = function () { | ||
|
||
let client = Loop54.getClient(common.endpoint); | ||
|
||
//mock all calls to the /autoComplete endpoint | ||
beforeEach(() => { | ||
nock(common.endpoint).post("/autoComplete").reply(200, autoCompleteResponse); | ||
}); | ||
|
||
var okFunc = function(response) { | ||
expect(response.status).to.equal(200); | ||
expect(response.data.queries.count).to.equal(1); | ||
} | ||
|
||
it("Returns 200 OK and a valid response, without callback", function () { | ||
return client.autoComplete("m").then(okFunc); | ||
}); | ||
|
||
it("Returns 200 OK and a valid response, with callback", function (done) { | ||
return client.autoComplete("m", response => common.testCallBack(response,okFunc,done)); | ||
}); | ||
|
||
it("Accepts options as second argument, without a callback", function () { | ||
return client.autoComplete("m", {}).then(okFunc); | ||
}); | ||
|
||
it("Accepts options as second argument, with a callback", function (done) { | ||
return client.autoComplete("m", {}, response => common.testCallBack(response,okFunc,done)); | ||
}); | ||
|
||
it("Returns error if it has too few arguments", function () { | ||
return client.autoComplete().catch(common.includesError); | ||
}); | ||
|
||
it("Returns error if it has too many arguments", function () { | ||
return client.autoComplete("m",{},"asdasd","asasd","g42om4").catch(common.includesError); | ||
}); | ||
|
||
it("Returns error if invalid search query, without callback", function () { | ||
return client.autoComplete("").catch(common.includesError); | ||
}); | ||
|
||
it("Returns error if invalid search query, with callback", function (done) { | ||
return client.autoComplete("",response => common.testCallBack(response,common.includesError,done)); | ||
}); | ||
import autoCompleteResponse from "./mocks/autocomplete-response-ok"; | ||
import nock from "nock"; | ||
import chai, { | ||
assert, | ||
expect | ||
} from "chai"; | ||
import common from "./common"; | ||
|
||
module.exports = function () { | ||
|
||
let client = Loop54.getClient(common.endpoint); | ||
|
||
//mock all calls to the /autoComplete endpoint | ||
beforeEach(() => { | ||
nock(common.endpoint).post("/autoComplete").reply(200, autoCompleteResponse); | ||
}); | ||
|
||
var okFunc = function(response) { | ||
expect(response.status).to.equal(200); | ||
expect(response.data.queries.count).to.equal(1); | ||
} | ||
|
||
it("Returns 200 OK and a valid response, without callback", function () { | ||
return client.autoComplete("m").then(okFunc); | ||
}); | ||
|
||
it("Returns 200 OK and a valid response, with callback", function (done) { | ||
client.autoComplete("m", response => common.testCallBack(response,okFunc,done)); | ||
}); | ||
|
||
it("Accepts options as second argument, without a callback", function () { | ||
return client.autoComplete("m", {}).then(okFunc); | ||
}); | ||
|
||
it("Accepts options as second argument, with a callback", function (done) { | ||
client.autoComplete("m", {}, response => common.testCallBack(response,okFunc,done)); | ||
}); | ||
|
||
it("Returns error if it has too few arguments", function () { | ||
return client.autoComplete().catch(common.includesError); | ||
}); | ||
|
||
it("Returns error if it has too many arguments", function () { | ||
return client.autoComplete("m",{},"asdasd","asasd","g42om4").catch(common.includesError); | ||
}); | ||
|
||
it("Returns error if invalid search query, without callback", function () { | ||
return client.autoComplete("").catch(common.includesError); | ||
}); | ||
|
||
it("Returns error if invalid search query, with callback", function (done) { | ||
client.autoComplete("",response => common.testCallBack(response,common.includesError,done)); | ||
}); | ||
} |
Oops, something went wrong.