blob: 2ca72c53349a66de477d9ef62c9a4e7ebc134168 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import { ErrorMsgComponent } from './error-msg.component';
import {ErrorMsgService} from "./error-msg.service";
import {ErrorMsgObject} from "./error-msg.model";
describe('ErrorMsgComponent', () => {
let component: ErrorMsgComponent;
let fixture: ComponentFixture<ErrorMsgComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ErrorMsgComponent],
providers: [ErrorMsgService]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ErrorMsgComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
test('should create', () => {
expect(component).toBeTruthy();
});
test('should triggerShowError fill error msg object', () => {
let errorMsgObj:ErrorMsgObject = new ErrorMsgObject("Title", "SubTitle", "Description")
component.errorMsgService.triggerShowError.next(errorMsgObj);
let errorMsg = component.errorMsgService.errorMsgObject;
expect(errorMsg).toBeDefined();
expect(errorMsg.title).toBe('Title');
expect(errorMsg.subtitle).toBe('SubTitle');
expect(errorMsg.description).toBe('Description');
});
test('should triggerClearError delete error msg object', () => {
let errorMsgObj:ErrorMsgObject = new ErrorMsgObject("Title", "SubTitle", "Description")
component.errorMsgService.triggerShowError.next(errorMsgObj);
let errorMsg = component.errorMsgService.errorMsgObject;
expect(errorMsg).toBeDefined();
component.errorMsgService.triggerClearError.next();
expect(component.errorMsgService.errorMsgObject).toBeNull();
});
});
|