diff options
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/error-msg/error-msg.component.spec.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/components/error-msg/error-msg.component.spec.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/shared/components/error-msg/error-msg.component.spec.ts b/vid-webpack-master/src/app/shared/components/error-msg/error-msg.component.spec.ts new file mode 100644 index 000000000..2ca72c533 --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/error-msg/error-msg.component.spec.ts @@ -0,0 +1,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(); + + }); +}); |