Skip to content

Commit 879bbab

Browse files
authored
Migrate remaining Sinon mocks to Vitest (mozilla#3885)
1 parent 786de36 commit 879bbab

25 files changed

Lines changed: 160 additions & 353 deletions

package-lock.json

Lines changed: 0 additions & 177 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"@types/react-tabs": "^2.3.4",
6464
"@types/reactour": "^1.18.1",
6565
"@types/shortid": "^0.0.29",
66-
"@types/sinon": "^10.0.1",
6766
"@types/styled-components": "^5.1.9",
6867
"@typescript-eslint/eslint-plugin": "^8.7.0",
6968
"@typescript-eslint/parser": "^8.7.0",
@@ -82,7 +81,6 @@
8281
"react-intersection-observer": "9.11.0",
8382
"rollup": "^3.29.5",
8483
"rollup-plugin-css-only": "^4.3.0",
85-
"sinon": "^13.0.2",
8684
"typescript": "^5.8.3",
8785
"utility-types": "^3.10.0",
8886
"vitest": "^4.0.9"

translate/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ At this stage, only the translation workspace is localizable. Until the full app
259259
- [Redux](https://redux.js.org/)
260260
- [create-react-app](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md)
261261
- [Vitest](https://vitest.dev/guide/#getting-started)
262-
- [sinon](https://sinonjs.org/releases/v6.0.0/)
263262
- [Linkify](https://tasti.github.io/react-linkify/)
264263
- [ReactTimeAgo](https://github.com/catamphetamine/react-time-ago)
265264
- [react-tabs](https://github.com/reactjs/react-tabs)

translate/src/hooks/usePluralExamples.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('usePluralExamples', () => {
2525
});
2626

2727
expect(res).toEqual({ 1: 1, 2: 2, 3: 3, 5: 0 });
28-
expect(consoleErrorSpy).toHaveBeenCalledTimes(0);
28+
expect(consoleErrorSpy).not.toHaveBeenCalled();
2929
});
3030

3131
it('prevents infinite loop if locale plurals are not configured properly', () => {
@@ -36,6 +36,6 @@ describe('usePluralExamples', () => {
3636
});
3737

3838
expect(res).toEqual({ 0: 1, 1: 2 });
39-
expect(consoleErrorSpy).toHaveBeenCalledTimes(1);
39+
expect(consoleErrorSpy).toHaveBeenCalledOnce();
4040
});
4141
});

translate/src/modules/batchactions/components/ApproveAll.test.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22
import { mount } from 'enzyme';
3-
import sinon from 'sinon';
43

54
import { MockLocalizationProvider } from '~/test/utils';
65

76
import { ApproveAll } from './ApproveAll';
7+
import { vi } from 'vitest';
88

99
const DEFAULT_BATCH_ACTIONS = {
1010
entities: [],
@@ -98,7 +98,7 @@ describe('<ApproveAll>', () => {
9898
});
9999

100100
it('performs approve all action when Approve All button is clicked', () => {
101-
const mockApproveAll = sinon.spy();
101+
const mockApproveAll = vi.fn();
102102

103103
const wrapper = mount(
104104
<WrapApproveAll
@@ -107,8 +107,8 @@ describe('<ApproveAll>', () => {
107107
/>,
108108
);
109109

110-
expect(mockApproveAll.called).toBeFalsy();
110+
expect(mockApproveAll).not.toHaveBeenCalled();
111111
wrapper.find('.approve-all').simulate('click');
112-
expect(mockApproveAll.called).toBeTruthy();
112+
expect(mockApproveAll).toHaveBeenCalled();
113113
});
114114
});

translate/src/modules/batchactions/components/RejectAll.test.jsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { mount } from 'enzyme';
22
import React from 'react';
3-
import sinon from 'sinon';
43

54
import { MockLocalizationProvider } from '~/test/utils';
65

76
import { RejectAll } from './RejectAll';
7+
import { vi } from 'vitest';
88

99
const DEFAULT_BATCH_ACTIONS = {
1010
entities: [],
@@ -98,7 +98,7 @@ describe('<RejectAll>', () => {
9898
});
9999

100100
it('raise confirmation warning when Reject All button is clicked', () => {
101-
const mockRejectAll = sinon.spy();
101+
const mockRejectAll = vi.fn();
102102

103103
const wrapper = mount(
104104
<WrapRejectAll
@@ -107,16 +107,15 @@ describe('<RejectAll>', () => {
107107
/>,
108108
);
109109

110-
expect(mockRejectAll.called).toBeFalsy();
111110
wrapper.find('.reject-all').simulate('click');
112-
expect(mockRejectAll.called).toBeFalsy();
111+
expect(mockRejectAll).not.toHaveBeenCalled();
113112
expect(wrapper.find('#batchactions-RejectAll--confirmation')).toHaveLength(
114113
1,
115114
);
116115
});
117116

118117
it('performs reject all action when Reject All button is confirmed', () => {
119-
const mockRejectAll = sinon.spy();
118+
const mockRejectAll = vi.fn();
120119

121120
const wrapper = mount(
122121
<WrapRejectAll
@@ -125,9 +124,9 @@ describe('<RejectAll>', () => {
125124
/>,
126125
);
127126

128-
expect(mockRejectAll.called).toBeFalsy();
127+
expect(mockRejectAll).not.toHaveBeenCalled();
129128
wrapper.find('.reject-all').simulate('click');
130129
wrapper.find('.reject-all').simulate('click');
131-
expect(mockRejectAll.called).toBeTruthy();
130+
expect(mockRejectAll).toHaveBeenCalled();
132131
});
133132
});

0 commit comments

Comments
 (0)