Skip to content

Commit 0ca893c

Browse files
committed
test: move test code and use toHaveBeenCalledTimes
1 parent 9fe5954 commit 0ca893c

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

apps/calendar/src/components/events/horizontalEvent.spec.tsx

+25-14
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,31 @@ describe(`Firing 'afterRenderEvent'`, () => {
141141
// Then
142142
expect(handler).not.toBeCalled();
143143
});
144+
145+
it(`should fire 'afterRenderEvent' when it is in readonly mode`, () => {
146+
// Given
147+
const { eventBus, handler } = setup();
148+
const uiModel = new EventUIModel(
149+
new EventModel({
150+
id: '1',
151+
start: new Date(2020, 0, 1, 10, 0),
152+
end: new Date(2020, 0, 1, 12, 0),
153+
isReadOnly: true,
154+
})
155+
);
156+
157+
const props = {
158+
uiModel,
159+
eventHeight: 30,
160+
headerHeight: 0,
161+
};
162+
163+
// When
164+
render(<HorizontalEvent {...props} />, { eventBus });
165+
166+
// Then
167+
expect(handler).toHaveBeenCalledTimes(1);
168+
});
144169
});
145170

146171
describe('Apply customStyle', () => {
@@ -366,18 +391,4 @@ describe('isReadOnly', () => {
366391

367392
expect(showDetailPopupSpy).toHaveBeenCalled();
368393
});
369-
370-
it(`should fire 'afterRenderEvent' when it is in readonly mode`, () => {
371-
// Given
372-
const eventBus = new EventBusImpl<ExternalEventTypes>();
373-
const handler = jest.fn();
374-
eventBus.on('afterRenderEvent', handler);
375-
const { props } = setup();
376-
377-
// When (resizingWidth)
378-
render(<HorizontalEvent {...props} />, { eventBus });
379-
380-
// Then
381-
expect(handler).toBeCalled();
382-
});
383394
});

0 commit comments

Comments
 (0)