2019-11-16 23:55:56 +01:00
|
|
|
import Notify from "common/notify";
|
2019-08-13 11:35:26 +02:00
|
|
|
let sinon = require("sinon");
|
|
|
|
|
2020-06-29 13:00:45 +02:00
|
|
|
let chai = require('../../../node_modules/chai/chai');
|
|
|
|
let assert = chai.assert;
|
|
|
|
|
2019-08-13 11:35:26 +02:00
|
|
|
describe("common/alert", () => {
|
2020-06-29 13:21:40 +02:00
|
|
|
|
|
|
|
let spywarn = sinon.spy(Notify, "warn");
|
2019-08-13 11:35:26 +02:00
|
|
|
it("should call alert.info", () => {
|
2019-11-16 23:55:56 +01:00
|
|
|
let spy = sinon.spy(Notify, "info");
|
|
|
|
Notify.info("message");
|
2019-08-13 11:35:26 +02:00
|
|
|
sinon.assert.calledOnce(spy);
|
|
|
|
spy.resetHistory();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should call alert.warning", () => {
|
2020-05-24 22:16:06 +02:00
|
|
|
Notify.warn("message");
|
2020-06-29 13:21:40 +02:00
|
|
|
sinon.assert.calledOnce(spywarn);
|
|
|
|
spywarn.resetHistory();
|
2019-08-13 11:35:26 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should call alert.error", () => {
|
2019-11-16 23:55:56 +01:00
|
|
|
let spy = sinon.spy(Notify, "error");
|
|
|
|
Notify.error("message");
|
2019-08-13 11:35:26 +02:00
|
|
|
sinon.assert.calledOnce(spy);
|
|
|
|
spy.resetHistory();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should call alert.success", () => {
|
2019-11-16 23:55:56 +01:00
|
|
|
let spy = sinon.spy(Notify, "success");
|
|
|
|
Notify.success("message");
|
2019-08-13 11:35:26 +02:00
|
|
|
sinon.assert.calledOnce(spy);
|
|
|
|
spy.resetHistory();
|
|
|
|
});
|
2020-06-29 13:00:45 +02:00
|
|
|
|
|
|
|
it("should call alert.logout", () => {
|
|
|
|
let spy = sinon.spy(Notify, "logout");
|
|
|
|
Notify.logout("message");
|
|
|
|
sinon.assert.calledOnce(spy);
|
|
|
|
spy.resetHistory();
|
|
|
|
});
|
|
|
|
|
2020-06-29 13:21:40 +02:00
|
|
|
it("should call wait", () => {
|
|
|
|
Notify.wait();
|
|
|
|
sinon.assert.calledOnce(spywarn);
|
|
|
|
spywarn.resetHistory();
|
|
|
|
});
|
|
|
|
|
2020-06-29 13:00:45 +02:00
|
|
|
//TODO How to access element?
|
|
|
|
/*it("should test blocking an unblocking UI", () => {
|
|
|
|
const el = document.getElementById("p-busy-overlay");
|
|
|
|
assert.equal(el.style.display, "xxx");
|
|
|
|
Notify.blockUI();
|
|
|
|
assert.equal(el.style.display, "xxx");
|
|
|
|
Notify.unblockUI();
|
|
|
|
assert.equal(el.style.display, "xxx");
|
|
|
|
});*/
|
2019-11-16 23:55:56 +01:00
|
|
|
});
|