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

51 lines
1.3 KiB
JavaScript
Raw Normal View History

import Notify from "common/notify";
2019-08-13 09:35:26 +00:00
let sinon = require("sinon");
2020-07-02 08:03:00 +00:00
let chai = require("chai/chai");
let assert = chai.assert;
2019-08-13 09:35:26 +00:00
describe("common/alert", () => {
2020-06-29 11:21:40 +00:00
let spywarn = sinon.spy(Notify, "warn");
let spyerror = sinon.spy(Notify, "error");
2019-08-13 09:35:26 +00:00
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", () => {
Notify.warn("message");
2020-06-29 11:21:40 +00:00
sinon.assert.calledOnce(spywarn);
spywarn.resetHistory();
2019-08-13 09:35:26 +00:00
});
it("should call alert.error", () => {
Notify.error("message");
sinon.assert.calledOnce(spyerror);
spyerror.resetHistory();
2019-08-13 09:35:26 +00:00
});
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();
});
2020-06-29 11:21:40 +00:00
it("should call wait", () => {
Notify.wait();
sinon.assert.calledOnce(spywarn);
spywarn.resetHistory();
});
});