diff --git a/unit-conversion/src/features/number-input-field/numberInputField.test.js b/unit-conversion/src/features/number-input-field/numberInputField.test.js index 5208c25687bf6634d12d4bcdfa6053e3c58e27e1..a392991641e169e9cca940ceeabae50d8883203a 100644 --- a/unit-conversion/src/features/number-input-field/numberInputField.test.js +++ b/unit-conversion/src/features/number-input-field/numberInputField.test.js @@ -1,58 +1,58 @@ -import { render, screen } from '@testing-library/react'; -import '../../testing/mockRedux.js'; -import { NumberInputField} from './numberInputField.js'; -import numberInputFieldSlice from '../number-input-field/numberInputFieldSlice.js'; - -import { - selectNumberOfUnits, - setNumberOfUnits, -} from './numberInputFieldSlice.js'; - -import { - selectCurrentInputUnit, -} from '../unit-selector/unitSelectorSlice.js'; - -describe('the NumberInputField slice', () => { - test('selects input value according to the store', () => { - const state = { - unitSelector: { - currentInputUnit: 'm', - currentOutputUnit: 'cm', - }, - numberInputField: { - numberToConvert: 10, - }, - }; - - const selectedInputUnit = selectNumberOfUnits(state); - expect(selectedInputUnit).toEqual(10); - }); -}); - -describe('the NumberInputField slice', () => { - test('setNumberOfUnits correctly adjusts state value', () => { - // This is what the local state looks like to the "setNumberOfUnits" reducer. - const state = numberInputFieldSlice.reducer({ - numberToConvert: 10, - }, setNumberOfUnits(100)); - - const numberOfUnits = 100; - expect(state.numberToConvert).toEqual(numberOfUnits); - }); -}); - -describe('the NumberInputField component', () => { - test('numberInputField displays apropriate content', () => { - jest.mock('../unit-selector/unitSelectorSlice.js', () => ({ - selectCurrentInputUnit: jest.fn().mockName('selectCurrentInputUnit'), - })); - - selectCurrentInputUnit.mockReturnValue('cm'); - - const { container } = render(<NumberInputField/>); - expect(screen.getByLabelText('inputField')).toHaveAttribute( - 'placeholder', expect.stringContaining('Enter # of "cm"'), - ); - expect(container).toMatchSnapshot(); - }); -}); +import { render, screen } from '@testing-library/react'; +import '../../testing/mockRedux.js'; +import { NumberInputField} from './numberInputField.js'; +import numberInputFieldSlice from '../number-input-field/numberInputFieldSlice.js'; + +import { + selectNumberOfUnits, + setNumberOfUnits, +} from './numberInputFieldSlice.js'; + +import { + selectCurrentInputUnit, +} from '../unit-selector/unitSelectorSlice.js'; + +describe('the NumberInputField slice', () => { + test('selects input value according to the store', () => { + const state = { + unitSelector: { + currentInputUnit: 'm', + currentOutputUnit: 'cm', + }, + numberInputField: { + numberToConvert: 10, + }, + }; + + const selectedInputUnit = selectNumberOfUnits(state); + expect(selectedInputUnit).toEqual(10); + }); +}); + +describe('the NumberInputField slice', () => { + test('setNumberOfUnits correctly adjusts state value', () => { + // This is what the local state looks like to the "setNumberOfUnits" reducer. + const state = numberInputFieldSlice.reducer({ + numberToConvert: 10, + }, setNumberOfUnits(100)); + + const numberOfUnits = 100; + expect(state.numberToConvert).toEqual(numberOfUnits); + }); +}); + +describe('the NumberInputField component', () => { + test('numberInputField displays apropriate content', () => { + jest.mock('../unit-selector/unitSelectorSlice.js', () => ({ + selectCurrentInputUnit: jest.fn().mockName('selectCurrentInputUnit'), + })); + + selectCurrentInputUnit.mockReturnValue('cm'); + + const { container } = render(<NumberInputField/>); + expect(screen.getByLabelText('inputField')).toHaveAttribute( + 'placeholder', expect.stringContaining('Enter # of "cm"'), + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/unit-conversion/src/features/unit-selector/unitSelector.test.js b/unit-conversion/src/features/unit-selector/unitSelector.test.js index 1ce0b938e163a216dced40422b7e48379e20e820..0fa4ddda415c0673a1ff12d9f9ee7b1000fd0ea2 100644 --- a/unit-conversion/src/features/unit-selector/unitSelector.test.js +++ b/unit-conversion/src/features/unit-selector/unitSelector.test.js @@ -1,66 +1,66 @@ -import '../../testing/mockRedux.js'; - -import unitSelectorSlice, { - selectCurrentInputUnit, - selectCurrentOutputUnit, - setCurrentInputUnit, - setCurrentOutputUnit, -} from './unitSelectorSlice.js'; - -describe('the UnitSelector slice', () => { - test('selects inputUnit value according to the store', () => { - const state = { - unitSelector: { - currentInputUnit: 'm', - currentOutputUnit: 'cm', - }, - numberInputField: { - numberToConvert: 10, - }, - }; - - const selectedInputUnit = selectCurrentInputUnit(state); - expect(selectedInputUnit).toEqual('m'); - }); -}); - -describe('the UnitSelector slice', () => { - test('selects outputUnit value according to the store', () => { - const state = { - unitSelector: { - currentInputUnit: 'm', - currentOutputUnit: 'cm', - }, - numberInputField: { - numberToConvert: 10, - }, - }; - - const selectedOutputUnit = selectCurrentOutputUnit(state); - expect(selectedOutputUnit).toEqual('cm'); - }); -}); - -describe('the UnitSelector slice', () => { - test('setcurrentInputUnit correctly adjusts state value', () => { - // This is what the local state looks like to the "setCurrentInputUnit" reducer. - const state = unitSelectorSlice.reducer({ - currentInputUnit: 'm', - currentOutputUnit: 'cm', - }, setCurrentInputUnit('km')); - - expect(state.currentInputUnit).toEqual('km'); - }); -}); - -describe('the UnitSelector slice', () => { - test('setcurrentOutputUnit correctly adjusts state value', () => { - // This is what the local state looks like to the "setCurrentOutputUnit" reducer. - const state = unitSelectorSlice.reducer({ - currentInputUnit: 'm', - currentOutputUnit: 'cm', - }, setCurrentOutputUnit('km')); - - expect(state.currentOutputUnit).toEqual('km'); - }); -}); +import '../../testing/mockRedux.js'; + +import unitSelectorSlice, { + selectCurrentInputUnit, + selectCurrentOutputUnit, + setCurrentInputUnit, + setCurrentOutputUnit, +} from './unitSelectorSlice.js'; + +describe('the UnitSelector slice', () => { + test('selects inputUnit value according to the store', () => { + const state = { + unitSelector: { + currentInputUnit: 'm', + currentOutputUnit: 'cm', + }, + numberInputField: { + numberToConvert: 10, + }, + }; + + const selectedInputUnit = selectCurrentInputUnit(state); + expect(selectedInputUnit).toEqual('m'); + }); +}); + +describe('the UnitSelector slice', () => { + test('selects outputUnit value according to the store', () => { + const state = { + unitSelector: { + currentInputUnit: 'm', + currentOutputUnit: 'cm', + }, + numberInputField: { + numberToConvert: 10, + }, + }; + + const selectedOutputUnit = selectCurrentOutputUnit(state); + expect(selectedOutputUnit).toEqual('cm'); + }); +}); + +describe('the UnitSelector slice', () => { + test('setcurrentInputUnit correctly adjusts state value', () => { + // This is what the local state looks like to the "setCurrentInputUnit" reducer. + const state = unitSelectorSlice.reducer({ + currentInputUnit: 'm', + currentOutputUnit: 'cm', + }, setCurrentInputUnit('km')); + + expect(state.currentInputUnit).toEqual('km'); + }); +}); + +describe('the UnitSelector slice', () => { + test('setcurrentOutputUnit correctly adjusts state value', () => { + // This is what the local state looks like to the "setCurrentOutputUnit" reducer. + const state = unitSelectorSlice.reducer({ + currentInputUnit: 'm', + currentOutputUnit: 'cm', + }, setCurrentOutputUnit('km')); + + expect(state.currentOutputUnit).toEqual('km'); + }); +});