photoprism/frontend/tests/unit/common/notify_test.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

import Notify from "common/notify";
2019-08-13 09:35:26 +00:00
let sinon = require("sinon");
let chai = require('../../../node_modules/chai/chai');
let assert = chai.assert;
2019-08-13 09:35:26 +00:00
describe("common/alert", () => {
it("should call alert.info", () => {
let spy = sinon.spy(Notify, "info");
Notify.info("message");
2019-08-13 09:35:26 +00:00
sinon.assert.calledOnce(spy);
spy.resetHistory();
});
it("should call alert.warning", () => {
let spy = sinon.spy(Notify, "warn");
Notify.warn("message");
2019-08-13 09:35:26 +00:00
sinon.assert.calledOnce(spy);
spy.resetHistory();
});
it("should call alert.error", () => {
let spy = sinon.spy(Notify, "error");
Notify.error("message");
2019-08-13 09:35:26 +00:00
sinon.assert.calledOnce(spy);
spy.resetHistory();
});
it("should call alert.success", () => {
let spy = sinon.spy(Notify, "success");
Notify.success("message");
2019-08-13 09:35:26 +00:00
sinon.assert.calledOnce(spy);
spy.resetHistory();
});
it("should call alert.logout", () => {
let spy = sinon.spy(Notify, "logout");
Notify.logout("message");
sinon.assert.calledOnce(spy);
spy.resetHistory();
});
//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");
});*/
});