Created
May 31, 2018 22:23
-
-
Save Devcon4/08f17920feb0ac6e070c62264c5d48cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* tslint:disable:no-unused-variable */ | |
| type booleanify<T> = { [P in keyof T]: boolean }; | |
| import { By } from '@angular/platform-browser'; | |
| import { DebugElement } from '@angular/core'; | |
| import { AppState, Store, dataReducer, DataActions, MiscActions } from '../../../cdux'; | |
| import { async, inject } from '@angular/core/testing'; | |
| import * as moment from 'moment'; | |
| import { ProcedureSchedulerComponent } from '../../../component/scheduleTools/procedureScheduler/procedureScheduler.component'; | |
| import { ScheduleItemOverview, ProcedureOption } from '../../../models/generated'; | |
| import { Dictionary, DataService } from '../../../models'; | |
| import { Observable } from 'rxjs/Observable'; | |
| /* end of imports */ | |
| describe('Component: procedureScheduler', () => { | |
| let testItems: Dictionary<ScheduleItemOverview[]> = new Dictionary<ScheduleItemOverview[]>({ | |
| 'Facility 1': [ | |
| new ScheduleItemOverview({ | |
| EndDate: moment('8/29/2016', 'M/DD/YYYY').add(14, 'days'), | |
| StartDate: moment('8/29/2016', 'M/DD/YYYY').add(7, 'days'), | |
| Id: 42, | |
| ScheduleItemTypeCode: 'I', | |
| StaffCount: 4, | |
| StaffCountIsTBD: true, | |
| Title: 'Test item 2!', | |
| }), | |
| new ScheduleItemOverview({ | |
| EndDate: moment('8/29/2016', 'M/DD/YYYY').add(6, 'days'), | |
| StartDate: moment('8/29/2016', 'M/DD/YYYY').add(1, 'days'), | |
| Id: 43, | |
| ScheduleItemTypeCode: 'I', | |
| StaffCount: 4, | |
| StaffCountIsTBD: true, | |
| Title: 'Test item 2!', | |
| }), | |
| new ScheduleItemOverview({ | |
| EndDate: moment('8/29/2016', 'M/DD/YYYY').add(17, 'days'), | |
| StartDate: moment('8/29/2016', 'M/DD/YYYY').add(10, 'days'), | |
| Id: 44, | |
| ScheduleItemTypeCode: 'P', | |
| StaffCount: 4, | |
| StaffCountIsTBD: true, | |
| Title: 'Test item 2!', | |
| }), | |
| ], | |
| 'Facility 2': [ | |
| new ScheduleItemOverview({ | |
| EndDate: moment('8/29/2016', 'M/DD/YYYY').add(14, 'days'), | |
| StartDate: moment('8/29/2016', 'M/DD/YYYY').add(7, 'days'), | |
| Id: 42, | |
| ScheduleItemTypeCode: 'I', | |
| StaffCount: 4, | |
| StaffCountIsTBD: true, | |
| Title: 'Test item 2!', | |
| }), | |
| new ScheduleItemOverview({ | |
| EndDate: moment('8/29/2016', 'M/DD/YYYY').add(6, 'days'), | |
| StartDate: moment('8/29/2016', 'M/DD/YYYY').add(1, 'days'), | |
| Id: 43, | |
| ScheduleItemTypeCode: 'I', | |
| StaffCount: 4, | |
| StaffCountIsTBD: true, | |
| Title: 'Test item 2!', | |
| }), | |
| new ScheduleItemOverview({ | |
| EndDate: moment('8/29/2016', 'M/DD/YYYY').add(17, 'days'), | |
| StartDate: moment('8/29/2016', 'M/DD/YYYY').add(10, 'days'), | |
| Id: 44, | |
| ScheduleItemTypeCode: 'P', | |
| StaffCount: 4, | |
| StaffCountIsTBD: true, | |
| Title: 'Test item 2!', | |
| }), | |
| ], | |
| }); | |
| let dataActions: DataActions = jasmine.createSpyObj('DataActions', ['getScheduleItemOverview']); | |
| let miscActions: MiscActions = jasmine.createSpyObj('MiscActions', ['clearScheduleItemOverviews']); | |
| let dataService: DataService = <any>{ scheduleItem: { getScheduleItemOverviews: id => Observable.of(null) } }; | |
| let store: Store; | |
| let component: ProcedureSchedulerComponent; | |
| (<any>dataActions).getScheduleItemOverview.and.returnValue(Observable.of({})); | |
| beforeEach(() => { | |
| let initialState = new AppState(); | |
| store = new Store(initialState, dataReducer); | |
| component = new ProcedureSchedulerComponent(store, dataActions, miscActions, null); | |
| }); | |
| it('should create an instance', () => { | |
| expect(component).toBeTruthy(); | |
| }); | |
| it('openPopover', () => { | |
| component.selectedScheduleItems = []; | |
| let si = new ScheduleItemOverview({ Title: 'test' }); | |
| (<any>dataActions).getScheduleItemOverview.and.returnValue(Observable.of(si)); | |
| component.openPopover(si, [si], { clientX: 1, clientY: 1, stopPropagation: () => {}, preventDefault: () => {} }); | |
| expect(component.displayPopover).toEqual(true); | |
| expect(component.xpos).toEqual(1); | |
| expect(component.ypos).toEqual(1); | |
| }); | |
| it('hidePopover', () => { | |
| component.displayPopover = true; | |
| component.hidePopover(); | |
| expect(component.displayPopover).toBeFalsy(); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment