Skip to content

Commit

Permalink
Remove sinon and replace sinon.spy() with jest.fn() (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
bedrich-schindler committed Sep 1, 2023
1 parent 4d49a8c commit fef54e6
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 205 deletions.
151 changes: 0 additions & 151 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
"prop-types": "^15.8.1",
"sass": "^1.66.1",
"sass-loader": "^13.3.2",
"sinon": "^14.0.2",
"stylelint": "^14.16.1",
"stylelint-webpack-plugin": "^4.1.1",
"terser-webpack-plugin": "^5.3.9",
Expand Down
5 changes: 2 additions & 3 deletions src/components/Alert/__tests__/Alert.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import sinon from 'sinon';
import {
render,
screen,
Expand Down Expand Up @@ -51,7 +50,7 @@ describe('rendering', () => {

describe('functionality', () => {
it('calls onClose() on Close button click', async () => {
const spy = sinon.spy();
const spy = jest.fn();
render((
<Alert
{...mandatoryProps}
Expand All @@ -60,6 +59,6 @@ describe('functionality', () => {
));

await userEvent.click(screen.getByTitle('Close'));
expect(spy.calledOnce).toEqual(true);
expect(spy).toHaveBeenCalled();
});
});
5 changes: 2 additions & 3 deletions src/components/Button/__tests__/Button.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
screen,
within,
} from '@testing-library/react';
import sinon from 'sinon';
import userEvent from '@testing-library/user-event';
import { actionColorPropTest } from '../../../../tests/propTests/actionColorPropTest';
import { blockPropTest } from '../../../../tests/propTests/blockPropTest';
Expand Down Expand Up @@ -157,7 +156,7 @@ describe('rendering', () => {

describe('functionality', () => {
it('calls synthetic event onClick()', async () => {
const spy = sinon.spy();
const spy = jest.fn();
render((
<Button
{...mandatoryProps}
Expand All @@ -166,6 +165,6 @@ describe('functionality', () => {
));

await userEvent.click(screen.getByText('label'));
expect(spy.calledOnce).toEqual(true);
expect(spy).toHaveBeenCalled();
});
});
5 changes: 2 additions & 3 deletions src/components/CheckboxField/__tests__/CheckboxField.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import sinon from 'sinon';
import {
render,
screen,
Expand Down Expand Up @@ -61,7 +60,7 @@ describe('rendering', () => {

describe('functionality', () => {
it('calls synthetic event onChange()', async () => {
const spy = sinon.spy();
const spy = jest.fn();
render((
<CheckboxField
{...mandatoryProps}
Expand All @@ -70,7 +69,7 @@ describe('functionality', () => {
));

await userEvent.click(screen.getByLabelText('label'));
expect(spy.calledOnce).toEqual(true);
expect(spy).toHaveBeenCalled();
});
});

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import sinon from 'sinon';
import {
render,
screen,
Expand Down Expand Up @@ -65,7 +64,7 @@ describe('rendering', () => {

describe('functionality', () => {
it('calls synthetic event onChange()', async () => {
const spy = sinon.spy();
const spy = jest.fn();
render((
<FileInputField
{...mandatoryProps}
Expand All @@ -75,6 +74,6 @@ describe('functionality', () => {

const file = new File(['hello'], 'hello.png', { type: 'image/png' });
await userEvent.upload(screen.getByLabelText('label'), file);
expect(spy.calledOnce).toEqual(true);
expect(spy).toHaveBeenCalled();
});
});
Loading

0 comments on commit fef54e6

Please sign in to comment.