Skip to content

Commit

Permalink
Tests: replace toHaveBeenCalledOnce and toBeCalledWith by toHaveBeenC…
Browse files Browse the repository at this point in the history
…alledExactlyOnceWith
  • Loading branch information
qmonmert committed Jan 26, 2025
1 parent a33f47c commit 10fd1ee
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,7 @@ describe('Landscape', () => {
const landscape = wrapper.find(wrappedElement('landscape-container'));
await landscape.trigger('mousedown', mouseEvent);

expect(cursorUpdater.set).toHaveBeenCalledOnce();
expect(cursorUpdater.set).toBeCalledWith('grabbing');
expect(cursorUpdater.set).toHaveBeenCalledExactlyOnceWith('grabbing');
});

it('should prevent default clicking event when defined', async () => {
Expand Down Expand Up @@ -909,8 +908,7 @@ describe('Landscape', () => {
await landscape.trigger('mousedown', mouseEventStart);
await landscape.trigger('mousemove', mouseEventGrabbed);

expect(landscapeScroller.scroll).toHaveBeenCalledOnce();
expect(landscapeScroller.scroll).toBeCalledWith(expect.anything(), 20, 20);
expect(landscapeScroller.scroll).toHaveBeenCalledExactlyOnceWith(expect.anything(), 20, 20);
});

it('should not scroll without starting grabbing', async () => {
Expand Down Expand Up @@ -1277,8 +1275,7 @@ describe('Landscape', () => {

expect(mockModuleRect).toHaveBeenCalled();
expect(mockContainerRect).toHaveBeenCalled();
expect(landscapeScroller.scrollIntoView).toHaveBeenCalledOnce();
expect(landscapeScroller.scrollIntoView).toHaveBeenCalledWith(prettierModule);
expect(landscapeScroller.scrollIntoView).toHaveBeenCalledExactlyOnceWith(prettierModule);
});

it('should not scroll if the highlighted module is already visible', async () => {
Expand Down Expand Up @@ -1321,8 +1318,7 @@ describe('Landscape', () => {

await performSearch(searchInput, '');

expect(landscapeScroller.scrollSmooth).toHaveBeenCalledOnce();
expect(landscapeScroller.scrollSmooth).toHaveBeenCalledWith(landscapeContainer, 0, 0);
expect(landscapeScroller.scrollSmooth).toHaveBeenCalledExactlyOnceWith(landscapeContainer, 0, 0);
});

const setupSearchTest = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ describe('LandscapeScroller', () => {

landscapeScroller.scroll(element, 10, 10);

expect(element.scroll).toHaveBeenCalledOnce();
expect(element.scroll).toBeCalledWith(10, 10);
expect(element.scroll).toHaveBeenCalledExactlyOnceWith(10, 10);
});

it('should scroll smooth', () => {
Expand All @@ -28,8 +27,7 @@ describe('LandscapeScroller', () => {

landscapeScroller.scrollSmooth(element, 10, 10);

expect(element.scroll).toHaveBeenCalledOnce();
expect(element.scroll).toBeCalledWith({ left: 10, top: 10, behavior: 'smooth' });
expect(element.scroll).toHaveBeenCalledExactlyOnceWith({ left: 10, top: 10, behavior: 'smooth' });
});

it('should scroll into view', () => {
Expand All @@ -38,7 +36,6 @@ describe('LandscapeScroller', () => {

landscapeScroller.scrollIntoView(element);

expect(element.scrollIntoView).toHaveBeenCalledOnce();
expect(element.scrollIntoView).toBeCalledWith({ behavior: 'smooth', block: 'center', inline: 'center' });
expect(element.scrollIntoView).toHaveBeenCalledExactlyOnceWith({ behavior: 'smooth', block: 'center', inline: 'center' });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ describe('MittAlertBus', () => {

mittAlertBus.success('A message');

expect(emitterStub.emit).toHaveBeenCalledOnce();
expect(emitterStub.emit).toBeCalledWith(AlertType.SUCCESS, 'A message');
expect(emitterStub.emit).toHaveBeenCalledExactlyOnceWith(AlertType.SUCCESS, 'A message');
});

it('should emit error', () => {
Expand All @@ -20,7 +19,6 @@ describe('MittAlertBus', () => {

mittAlertBus.error('A message');

expect(emitterStub.emit).toHaveBeenCalledOnce();
expect(emitterStub.emit).toBeCalledWith(AlertType.ERROR, 'A message');
expect(emitterStub.emit).toHaveBeenCalledExactlyOnceWith(AlertType.ERROR, 'A message');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ describe('MittAlertListener', () => {

emitter.emit(AlertType.SUCCESS, 'A message');

expect(spyAlerted).toHaveBeenCalledOnce();
expect(spyAlerted).toBeCalledWith('A message');
expect(spyAlerted).toHaveBeenCalledExactlyOnceWith('A message');
});

it('should unsubscribe success', () => {
Expand All @@ -39,8 +38,7 @@ describe('MittAlertListener', () => {

emitter.emit(AlertType.ERROR, 'A message');

expect(spyAlerted).toHaveBeenCalledOnce();
expect(spyAlerted).toBeCalledWith('A message');
expect(spyAlerted).toHaveBeenCalledExactlyOnceWith('A message');
});

it('should unsubscribe error', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('ConsoleLogger', () => {

consoleLogger.error('An error occurs', error);

expect(logger.error).toHaveBeenCalledOnce();
expect(logger.error).toBeCalledWith('An error occurs\n', error);
expect(logger.error).toHaveBeenCalledExactlyOnceWith('An error occurs\n', error);
});
});

0 comments on commit 10fd1ee

Please sign in to comment.