diff --git a/js/renovation/ui/scheduler/appointment/appointment.tsx b/js/renovation/ui/scheduler/appointment/appointment.tsx index d39c39b2366b..b082ca25d4ff 100644 --- a/js/renovation/ui/scheduler/appointment/appointment.tsx +++ b/js/renovation/ui/scheduler/appointment/appointment.tsx @@ -174,8 +174,10 @@ AppointmentProps, } onItemClick(): void { + const viewModel = { ...this.props.viewModel, color: this.color }; + const e = { - data: [this.props.viewModel], + data: [viewModel], target: this.ref.current as HTMLDivElement, index: this.props.index, }; diff --git a/js/renovation/ui/scheduler/appointment/tooltip/__tests__/appointment_list.test.tsx b/js/renovation/ui/scheduler/appointment/tooltip/__tests__/appointment_list.test.tsx index f2ea2986324e..882e23652546 100644 --- a/js/renovation/ui/scheduler/appointment/tooltip/__tests__/appointment_list.test.tsx +++ b/js/renovation/ui/scheduler/appointment/tooltip/__tests__/appointment_list.test.tsx @@ -1,5 +1,7 @@ +import React from 'react'; import { shallow, ShallowWrapper } from 'enzyme'; -import { viewFunction } from '../appointment_list'; +import { viewFunction as ViewFunction } from '../appointment_list'; +import { List } from '../../../../list'; describe('Appointment list', () => { const defaultViewModel = { @@ -34,20 +36,20 @@ describe('Appointment list', () => { describe('Render', () => { const render = (viewModel = {} as any): ShallowWrapper => shallow( - viewFunction({ - ...viewModel, - props: { + , ); - it('it should have correct render', () => { + it('should have correct render', () => { const list = render(); - expect(list.is('div')) - .toBe(true); + expect(list.type()) + .toBe(List); }); }); }); diff --git a/js/renovation/ui/scheduler/appointment/tooltip/__tests__/delete_button.test.tsx b/js/renovation/ui/scheduler/appointment/tooltip/__tests__/delete_button.test.tsx index 1aa3ec3921af..9beaf1a0a2a1 100644 --- a/js/renovation/ui/scheduler/appointment/tooltip/__tests__/delete_button.test.tsx +++ b/js/renovation/ui/scheduler/appointment/tooltip/__tests__/delete_button.test.tsx @@ -6,7 +6,7 @@ describe('Delete button', () => { describe('Render', () => { const render = (): ShallowWrapper => shallow(viewFunction()); - it('it should have correct render', () => { + it('should have correct render', () => { const buttonContainer = render(); const button = buttonContainer.childAt(0); diff --git a/js/renovation/ui/scheduler/appointment/tooltip/__tests__/item_layout.test.tsx b/js/renovation/ui/scheduler/appointment/tooltip/__tests__/item_layout.test.tsx index 56f3ec5deb52..6e3a1db2a986 100644 --- a/js/renovation/ui/scheduler/appointment/tooltip/__tests__/item_layout.test.tsx +++ b/js/renovation/ui/scheduler/appointment/tooltip/__tests__/item_layout.test.tsx @@ -11,13 +11,15 @@ describe('Tooltip item', () => { viewFunction({ ...viewModel, props: { - appointments: [], + item: { + color: 'color', + }, ...viewModel.props, }, }), ); - it('it should have correct default render', () => { + it('should have correct default render', () => { const item = render(); const markerBody = item.childAt(0); const tooltipItemContent = item.childAt(1); diff --git a/js/renovation/ui/scheduler/appointment/tooltip/__tests__/marker.test.tsx b/js/renovation/ui/scheduler/appointment/tooltip/__tests__/marker.test.tsx index 07b98a7ba38f..f4f27beac397 100644 --- a/js/renovation/ui/scheduler/appointment/tooltip/__tests__/marker.test.tsx +++ b/js/renovation/ui/scheduler/appointment/tooltip/__tests__/marker.test.tsx @@ -1,12 +1,15 @@ import { shallow, ShallowWrapper } from 'enzyme'; -import { viewFunction } from '../marker'; +import { Marker, viewFunction } from '../marker'; describe('Tooltip marker', () => { - describe('Render', () => { - const render = (): ShallowWrapper => shallow(viewFunction()); + const render = (viewModel): ShallowWrapper => shallow(viewFunction({ + ...viewModel, + props: { ...viewModel.props }, + })); - it('it should have correct render', () => { - const marker = render(); + describe('Render', () => { + it('should have correct render', () => { + const marker = render({}); const markerBody = marker.childAt(0); expect(marker.is('div')) @@ -21,5 +24,33 @@ describe('Tooltip marker', () => { expect(markerBody.hasClass('dx-tooltip-appointment-item-marker-body')) .toBe(true); }); + + it('should set color correctly', () => { + const marker = render({ + style: { background: 'appointmentColor' }, + }); + + const childDiv = marker.find('.dx-tooltip-appointment-item-marker-body'); + expect(childDiv.prop('style')) + .toEqual({ + background: 'appointmentColor', + }); + }); + }); + + describe('Logic', () => { + describe('Getters', () => { + describe('style', () => { + it('should return correct style', () => { + const color = 'color'; + + const marker = new Marker({}); + marker.props.color = color; + + expect(marker.style) + .toEqual({ background: 'color' }); + }); + }); + }); }); }); diff --git a/js/renovation/ui/scheduler/appointment/tooltip/appointment_list.tsx b/js/renovation/ui/scheduler/appointment/tooltip/appointment_list.tsx index 4fd93dd14b28..ab011c5a3446 100644 --- a/js/renovation/ui/scheduler/appointment/tooltip/appointment_list.tsx +++ b/js/renovation/ui/scheduler/appointment/tooltip/appointment_list.tsx @@ -6,17 +6,13 @@ import { } from '@devextreme-generator/declarations'; import { TooltipItemLayout } from './item_layout'; import { AppointmentViewModel } from '../types'; +import { List } from '../../../list'; export const viewFunction = (viewModel: AppointmentList): JSX.Element => ( -
- {viewModel.props.appointments.map((item, index) => ( - - ))} -
+ ); @ComponentBindings() diff --git a/js/renovation/ui/scheduler/appointment/tooltip/item_layout.tsx b/js/renovation/ui/scheduler/appointment/tooltip/item_layout.tsx index 56dfbca24f1d..1d737fba2375 100644 --- a/js/renovation/ui/scheduler/appointment/tooltip/item_layout.tsx +++ b/js/renovation/ui/scheduler/appointment/tooltip/item_layout.tsx @@ -6,18 +6,24 @@ import { TooltipItemContent } from './item_content'; import { AppointmentViewModel } from '../types'; import { DeleteButton } from './delete_button'; -export const viewFunction = (viewModel: TooltipItemLayout): JSX.Element => ( -
- - - -
-); +export const viewFunction = (viewModel: TooltipItemLayout): JSX.Element => { + const { color } = viewModel.props.item; + + return ( +
+ + + +
+ ); +}; @ComponentBindings() export class TooltipItemLayoutProps { diff --git a/js/renovation/ui/scheduler/appointment/tooltip/marker.tsx b/js/renovation/ui/scheduler/appointment/tooltip/marker.tsx index 1b5613a950f1..750da0727073 100644 --- a/js/renovation/ui/scheduler/appointment/tooltip/marker.tsx +++ b/js/renovation/ui/scheduler/appointment/tooltip/marker.tsx @@ -1,13 +1,14 @@ import { - Component, ComponentBindings, JSXComponent, OneWay, + Component, ComponentBindings, CSSAttributes, JSXComponent, OneWay, } from '@devextreme-generator/declarations'; -export const viewFunction = (): JSX.Element => ( +export const viewFunction = (viewModel: Marker): JSX.Element => (
); @@ -22,4 +23,7 @@ export class MarkerProps { view: viewFunction, }) export class Marker extends JSXComponent(MarkerProps) { + get style(): CSSAttributes { + return { background: this.props.color }; + } } diff --git a/js/renovation/ui/scheduler/appointment/types.ts b/js/renovation/ui/scheduler/appointment/types.ts index 8eb39c288993..989d4031ac1f 100644 --- a/js/renovation/ui/scheduler/appointment/types.ts +++ b/js/renovation/ui/scheduler/appointment/types.ts @@ -40,6 +40,7 @@ export interface AppointmentViewModel { appointment: AppointmentData; geometry: AppointmentGeometry; info: AppointmentInfo; + color?: string; } export interface OverflowIndicatorViewModel {