Skip to content
Snippets Groups Projects
Commit 6f842215 authored by Gabriel Clark's avatar Gabriel Clark
Browse files

Added return value mocking to the component unit test.

parent 5d68569e
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,7 @@ exports[`the NumberInputField component numberInputField displays apropriate con ...@@ -13,7 +13,7 @@ exports[`the NumberInputField component numberInputField displays apropriate con
<input <input
class="inputField" class="inputField"
id="inputField" id="inputField"
placeholder="Enter # of \\"undefined\\"" placeholder="Enter # of \\"cm\\""
type="text" type="text"
/> />
</div> </div>
......
...@@ -8,11 +8,9 @@ import { ...@@ -8,11 +8,9 @@ import {
setNumberOfUnits, setNumberOfUnits,
} from './numberInputFieldSlice.js'; } from './numberInputFieldSlice.js';
/*
import { import {
selectCurrentInputUnit, selectCurrentInputUnit,
} from '../unit-selector/unitSelectorSlice.js'; } from '../unit-selector/unitSelectorSlice.js';
*/
jest.mock('../unit-selector/unitSelectorSlice.js', () => ({ jest.mock('../unit-selector/unitSelectorSlice.js', () => ({
selectCurrentInputUnit: jest.fn().mockName('selectCurrentInputUnit'), selectCurrentInputUnit: jest.fn().mockName('selectCurrentInputUnit'),
...@@ -49,12 +47,11 @@ describe('the NumberInputField slice', () => { ...@@ -49,12 +47,11 @@ describe('the NumberInputField slice', () => {
describe('the NumberInputField component', () => { describe('the NumberInputField component', () => {
test('numberInputField displays apropriate content', () => { test('numberInputField displays apropriate content', () => {
// HOW DO I GET THIS TO WORK???? selectCurrentInputUnit.mockReturnValue('cm');
// selectCurrentInputUnit.mockReturnValue('cm');
const { container } = render(<NumberInputField/>); const { container } = render(<NumberInputField/>);
expect(screen.getByLabelText('inputField')).toHaveAttribute( expect(screen.getByLabelText('inputField')).toHaveAttribute(
'placeholder', expect.stringContaining('Enter # of "undefined"'), 'placeholder', expect.stringContaining('Enter # of "cm"'),
); );
expect(container).toMatchSnapshot(); expect(container).toMatchSnapshot();
}); });
......
import '@testing-library/jest-dom/extend-expect'; import '@testing-library/jest-dom/extend-expect';
afterEach(() => {
jest.clearAllMocks();
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment