From 1185d274c61ba4e238746a7717ba3741503dd330 Mon Sep 17 00:00:00 2001 From: Matt Lewis Date: Sun, 5 Aug 2018 13:52:54 -0700 Subject: [PATCH] feat: expose the full week view on the beforeViewRender output Closes #632 --- src/modules/week/calendar-week-view.component.ts | 5 ++--- test/calendar-week-view.component.spec.ts | 16 ++++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/modules/week/calendar-week-view.component.ts b/src/modules/week/calendar-week-view.component.ts index 2a4e7f051..ddb81ba37 100644 --- a/src/modules/week/calendar-week-view.component.ts +++ b/src/modules/week/calendar-week-view.component.ts @@ -59,9 +59,8 @@ export interface WeekViewAllDayEventResize { edge: string; } -export interface CalendarWeekViewBeforeRenderEvent { +export interface CalendarWeekViewBeforeRenderEvent extends WeekView { header: WeekDay[]; - period: ViewPeriod; } /** @@ -901,7 +900,7 @@ export class CalendarWeekViewComponent implements OnChanges, OnInit, OnDestroy { if (this.days && this.view) { this.beforeViewRender.emit({ header: this.days, - period: this.view.period + ...this.view }); } } diff --git a/test/calendar-week-view.component.spec.ts b/test/calendar-week-view.component.spec.ts index f9ec0d600..c04328467 100644 --- a/test/calendar-week-view.component.spec.ts +++ b/test/calendar-week-view.component.spec.ts @@ -1109,16 +1109,12 @@ describe('calendarWeekView component', () => { fixture.componentInstance.ngOnInit(); fixture.componentInstance.viewDate = new Date('2016-06-27'); fixture.componentInstance.ngOnChanges({ viewDate: {} }); - expect( - beforeViewRenderCalled.getCall(0).args[0].period.start - ).to.be.an.instanceOf(Date); - expect( - beforeViewRenderCalled.getCall(0).args[0].period.end - ).to.be.an.instanceOf(Date); - expect( - Array.isArray(beforeViewRenderCalled.getCall(0).args[0].period.events) - ).to.equal(true); - fixture.destroy(); + const data = beforeViewRenderCalled.getCall(0).args[0]; + expect(data.period.start).to.be.an.instanceOf(Date); + expect(data.period.end).to.be.an.instanceOf(Date); + expect(Array.isArray(data.period.events)).to.equal(true); + expect(Array.isArray(data.allDayEventRows)).to.be.true; + expect(Array.isArray(data.hourColumns)).to.be.true; }); it('should add event actions to each event', () => {