summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-01-10 13:53:53 +0100
committerMarcello Stanisci <stanisci.m@gmail.com>2018-01-10 13:53:53 +0100
commitf5bca274a91bc9eadb9e6c521fde723649eed405 (patch)
treef75001528d1d8d0826b26546b4582e87605e79b5
parenta260f2755ba9532cad599b1a5374b694f169ea57 (diff)
downloadbackoffice-f5bca274a91bc9eadb9e6c521fde723649eed405.tar.gz
backoffice-f5bca274a91bc9eadb9e6c521fde723649eed405.tar.bz2
backoffice-f5bca274a91bc9eadb9e6c521fde723649eed405.zip
testing the reaction to a order id not found
-rw-r--r--js/test/main.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/js/test/main.js b/js/test/main.js
index 2ded74e..e898210 100644
--- a/js/test/main.js
+++ b/js/test/main.js
@@ -13,6 +13,7 @@ ava.test.beforeEach(t => {
// Global 'document' mock
global.document = {};
global.document.addEventListener = function(){};
+ global.alert = console.log;
// Load back-office code
t.context.bo = require("../backoffice");
@@ -20,14 +21,22 @@ ava.test.beforeEach(t => {
// Remove mocks from global scope
ava.test.afterEach(t => {
+ // Is this done by the garbage collector anyway?
delete global.XMLHttpRequest;
delete global.document;
+ delete global.alert;
+ delete t.context.xhr;
+ delete t.context.requests;
});
-ava.test("orders tracking", (t) => {
+ava.test("Order id not found", (t) => {
+ /**
+ * FIXME: improve the reaction to a order id not found.
+ * Alerting a message is not acceptable.
+ */
+ var alert = sinon.spy(global, "alert");
t.context.bo.track_order(22);
-
- // Clean up
- t.context.xhr.restore();
+ t.context.requests[0].respond(404);
+ sinon.assert.calledWith(alert, "Order ID unknown");
t.pass();
});