Skip to content

Commit

Permalink
feat: expose the full week view on the beforeViewRender output
Browse files Browse the repository at this point in the history
Closes #632
  • Loading branch information
mattlewis92 committed Aug 5, 2018
1 parent df339b9 commit 1185d27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/modules/week/calendar-week-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ export interface WeekViewAllDayEventResize {
edge: string;
}

export interface CalendarWeekViewBeforeRenderEvent {
export interface CalendarWeekViewBeforeRenderEvent extends WeekView {
header: WeekDay[];
period: ViewPeriod;
}

/**
Expand Down Expand Up @@ -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
});
}
}
Expand Down
16 changes: 6 additions & 10 deletions test/calendar-week-view.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 1185d27

Please sign in to comment.