Commit 024d60597ce1b478ec866dfbe4c1aa8be5ae59ba

Authored by Victor Costa
1 parent c42991a6

Add tests to notification component

src/app/components/notification/notification.component.spec.ts
... ... @@ -13,6 +13,20 @@ describe("Components", () => {
13 13  
14 14 beforeEach(angular.mock.module("templates"));
15 15  
  16 + it("display an error message when notify an error", done => {
  17 + let sweetAlert = jasmine.createSpyObj("sweetAlert", ["swal"]);
  18 + sweetAlert.swal = jasmine.createSpy("swal");
  19 +
  20 + let component: Notification = new Notification(<any>helpers.mocks.$log, <any>sweetAlert, <any>helpers.mocks.translatorService);
  21 + component.error("message", "title");
  22 + expect(sweetAlert.swal).toHaveBeenCalledWith(jasmine.objectContaining({
  23 + text: "message",
  24 + title: "title",
  25 + type: "error"
  26 + }));
  27 + done();
  28 + });
  29 +
16 30 it("use the default message when call notification component without a message", done => {
17 31 let sweetAlert = jasmine.createSpyObj("sweetAlert", ["swal"]);
18 32 sweetAlert.swal = jasmine.createSpy("swal");
... ...