From b6c89f132d226d4ea44a0eb9e3390180d5ccab99 Mon Sep 17 00:00:00 2001
From: jackmnolley <jackmnolley@gmail.com>
Date: Mon, 13 Sep 2021 00:08:01 -0500
Subject: [PATCH] Updated with my changes

---
 .../numberInputField.test.js                  | 133 ++++++++--------
 .../unit-selector/unitSelector.test.js        | 146 +++++++++---------
 2 files changed, 137 insertions(+), 142 deletions(-)

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 34e339b..0a7ea78 100644
--- a/unit-conversion/src/features/number-input-field/numberInputField.test.js
+++ b/unit-conversion/src/features/number-input-field/numberInputField.test.js
@@ -1,68 +1,65 @@
-// import { render, screen } from '@testing-library/react';
-import '../../testing/mockRedux.js';
-// import { NumberInputField, internals } from './numberInputField.js';
-import numberInputFieldSlice from '../number-input-field/numberInputFieldSlice.js';
-
-import {
-  selectNumberOfUnits,
-  setNumberOfUnits,
-} from './numberInputFieldSlice.js';
-/*
-import {
-  selectCurrentInputUnit,
-  selectCurrentOutputUnit,
-} 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);
-  });
-});
-
-jest.mock('./numberInputField.js', () => ({
-  selectNumberOfUnits: jest.fn().mockName('selectNumberOfUnits'),
-}));
-
-jest.mock('../unit-selector/unitSelectorSlice.js', () => ({
-  selectCurrentInputUnit: jest.fn().mockName('selectCurrentInputUnit'),
-  selectCurrentOutputUnit: jest.fn().mockName('selectCurrentOutputUnit'),
-}));
-
-/*
-describe('the NumberInputField component', () => {
-  test('numberInputField displays apropriate content', () => {
-    selectNumberOfUnits.mockReturnValue(10);
-    selectCurrentInputUnit.mockReturnValue('cm');
-    selectCurrentOutputUnit.mockReturnValue('cm');
-
-    render(<NumberInputField/>);
-    expect(screen.getByLabelText('inputField')).toHaveAttribute(
-      'placeholder', expect.stringContaining('Enter # of "cm"'),
-    );
-  });
-});
-*/
+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,
+  selectCurrentOutputUnit,
+} 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);
+  });
+});
+
+jest.mock('./numberInputField.js', () => ({
+  selectNumberOfUnits: jest.fn().mockName('selectNumberOfUnits'),
+}));
+
+jest.mock('../unit-selector/unitSelectorSlice.js', () => ({
+  selectCurrentInputUnit: jest.fn().mockName('selectCurrentInputUnit'),
+  selectCurrentOutputUnit: jest.fn().mockName('selectCurrentOutputUnit'),
+}));
+
+describe('the NumberInputField component', () => {
+  test('numberInputField displays apropriate content', () => {
+    selectNumberOfUnits.mockReturnValue(10);
+    selectCurrentInputUnit.mockReturnValue('cm');
+    selectCurrentOutputUnit.mockReturnValue('cm');
+
+    render(<NumberInputField/>);
+    expect(screen.getByLabelText('inputField')).toHaveAttribute(
+      'placeholder', expect.stringContaining('Enter # of "cm"'),
+    );
+  });
+});
diff --git a/unit-conversion/src/features/unit-selector/unitSelector.test.js b/unit-conversion/src/features/unit-selector/unitSelector.test.js
index bf80068..a1cb13a 100644
--- a/unit-conversion/src/features/unit-selector/unitSelector.test.js
+++ b/unit-conversion/src/features/unit-selector/unitSelector.test.js
@@ -1,74 +1,72 @@
-// import { render, screen } from '@testing-library/react';
-import '../../testing/mockRedux.js';
-// import { UnitSelector } from './unitSelector.js';
-
-/*
-import {
-  selectNumberOfUnits,
-} from '../number-input-field/numberInputFieldSlice.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 { render, screen } from '@testing-library/react';
+import '../../testing/mockRedux.js';
+import { UnitSelector } from './unitSelector.js';
+
+import {
+  selectNumberOfUnits,
+} from '../number-input-field/numberInputFieldSlice.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');
+  });
+});
-- 
GitLab