summaryrefslogtreecommitdiff
path: root/js/test/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/test/main.js')
-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();
});