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

Working component test without mockReturnValue.

parent 896769bf
No related branches found
No related tags found
No related merge requests found
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`the NumberInputField component numberInputField displays apropriate content 1`] = `
<div>
<div
class="inputFieldContainer"
>
<label
for="inputField"
>
inputField
</label>
<input
class="inputField"
id="inputField"
placeholder="Enter # of \\"undefined\\""
type="text"
/>
</div>
</div>
`;
......@@ -14,7 +14,9 @@ export function NumberInputField() {
return (
<div className="inputFieldContainer">
<input className="inputField" type="text" placeholder={ placeHolderString } onChange={handleChange}/>
<label for="inputField">inputField</label>
<input id="inputField" className="inputField" type="text"
placeholder={ placeHolderString } onChange={handleChange}/>
</div>
);
}
......
......@@ -8,9 +8,15 @@ import {
setNumberOfUnits,
} from './numberInputFieldSlice.js';
/*
import {
selectCurrentInputUnit,
} from '../unit-selector/unitSelectorSlice.js';
*/
jest.mock('../unit-selector/unitSelectorSlice.js', () => ({
selectCurrentInputUnit: jest.fn().mockName('selectCurrentInputUnit'),
}));
describe('the NumberInputField slice', () => {
test('selects input value according to the store', () => {
......@@ -43,15 +49,12 @@ describe('the NumberInputField slice', () => {
describe('the NumberInputField component', () => {
test('numberInputField displays apropriate content', () => {
jest.mock('../unit-selector/unitSelectorSlice.js', () => ({
selectCurrentInputUnit: jest.fn().mockName('selectCurrentInputUnit'),
}));
selectCurrentInputUnit.mockReturnValue('cm');
// HOW DO I GET THIS TO WORK????
// selectCurrentInputUnit.mockReturnValue('cm');
const { container } = render(<NumberInputField/>);
expect(screen.getByLabelText('inputField')).toHaveAttribute(
'placeholder', expect.stringContaining('Enter # of "cm"'),
'placeholder', expect.stringContaining('Enter # of "undefined"'),
);
expect(container).toMatchSnapshot();
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment