Skip to content

Commit 11500f5

Browse files
authored
Merge pull request #59 from oslabs-beta/v4_stage
V4 stage
2 parents 4d37e28 + 3159c74 commit 11500f5

File tree

23 files changed

+110
-164
lines changed

23 files changed

+110
-164
lines changed

src/components/Modals/ExportFileModal.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const ExportFileModal = ({ isExportModalOpen, setIsExportModalOpen }) => {
6363

6464
const displayTestFile = (testFolderFilePath) => {
6565
const fileContent = fs.readFileSync(testFolderFilePath + `/${fileName}.test.js`, 'utf8');
66-
console.log('fileContent: ', fileContent);
6766
dispatchToGlobal(updateFile(fileContent));
6867
dispatchToGlobal(toggleFolderView(testFolderFilePath));
6968
dispatchToGlobal(highlightFile(`${fileName}.test.js`));

src/components/Modals/Modal.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const Modal = ({
5050
<pre>
5151
<div className='code-wrapper'>
5252
<code ref={codeRef}>{script}</code>
53+
<p id={styles.endpoint}>Note if you are using Create React App do not install jest</p>
5354
</div>
5455
</pre>
5556
)}

src/components/Modals/modalHooks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ export function useGenerateScript(test) {
4141
case 'react':
4242
return (
4343
`cd ${projectFilePath}\n` +
44-
'npm i -D jest @testing-library/jest-dom @testing-library/react test-data-bot\n' +
44+
'npm i -D @testing-library/jest-dom @testing-library/react test-data-bot jest\n' +
4545
'npm run test'
4646
);
4747
case 'redux':
4848
return (
4949
`cd ${projectFilePath}\n` +
50-
'npm i -D jest @testing-library/jest-dom @testing-library/react test-data-bot redux-mock-store redux-thunk fetch-mock\n' +
50+
'npm i -D @testing-library/jest-dom @testing-library/react test-data-bot redux-mock-store redux-thunk fetch-mock node-fetch jest\n' +
5151
'npm run test'
5252
);
5353
case 'hooks':
5454
return (
5555
`cd ${projectFilePath}\n` +
56-
'npm i -D jest @testing-library/jest-dom @testing-library/react test-data-bot @testing-library/react-hooks\n' +
56+
'npm i -D @testing-library/jest-dom @testing-library/react test-data-bot @testing-library/react-hooks jest\n' +
5757
'npm run test'
5858
);
5959
case 'endpoint':

src/components/NavBar/NavBar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const homeIcon = require('../../assets/images/home.png');
2626

2727
const NavBar = () => {
2828
const [
29-
{ fileTree, isFileDirectoryOpen, url, projectUrl, rightPanelDisplay },
29+
{ fileTree, isFileDirectoryOpen, projectUrl, rightPanelDisplay },
3030
dispatchToGlobal,
3131
] = useContext(GlobalContext);
3232
const [isExportModalOpen, setIsExportModalOpen] = useState(false);

src/components/ReduxTestComponent/ActionCreator/ActionCreator.jsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
import React, { useContext } from 'react';
22
import { Draggable } from 'react-beautiful-dnd';
33
import styles from './ActionCreator.module.scss';
4-
import { GlobalContext } from '../../../context/reducers/globalReducer';
54
import { ReduxTestCaseContext } from '../../../context/reducers/reduxTestCaseReducer';
65
import {
76
deleteActionCreator,
87
updateActionCreator,
9-
updateActionsFilePath,
10-
updateTypesFilePath,
118
} from '../../../context/actions/reduxTestCaseActions';
12-
import SearchInput from '../../SearchInput/SearchInput';
139

1410
const closeIcon = require('../../../assets/images/close.png');
1511
const dragIcon = require('../../../assets/images/drag-vertical.png');
1612

1713
const ActionCreator = ({ actionCreator, index }) => {
18-
const [{ filePathMap }] = useContext(GlobalContext);
1914
const [, dispatchToReduxTestCase] = useContext(ReduxTestCaseContext);
2015

2116
const handleChangeActionCreatorFields = (e, field) => {

src/components/ReduxTestComponent/Middleware/Middleware.jsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
import React, { useContext } from 'react';
22
import { Draggable } from 'react-beautiful-dnd';
33
import styles from './Middleware.module.scss';
4-
import { GlobalContext } from '../../../context/reducers/globalReducer';
54
import { ReduxTestCaseContext } from '../../../context/reducers/reduxTestCaseReducer';
6-
import {
7-
deleteMiddleware,
8-
updateMiddleware,
9-
updateMiddlewaresFilePath,
10-
} from '../../../context/actions/reduxTestCaseActions';
11-
import SearchInput from '../../SearchInput/SearchInput';
5+
import { deleteMiddleware, updateMiddleware } from '../../../context/actions/reduxTestCaseActions';
126

137
const closeIcon = require('../../../assets/images/close.png');
148
const dragIcon = require('../../../assets/images/drag-vertical.png');
159

1610
const Middleware = ({ middleware, index }) => {
17-
const [{ filePathMap }] = useContext(GlobalContext);
1811
const [, dispatchToReduxTestCase] = useContext(ReduxTestCaseContext);
1912

2013
const handleChangeMiddlewareFields = (e, field) => {

src/components/ReduxTestComponent/Reducer/Reducer.jsx

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Draggable } from 'react-beautiful-dnd';
33
import styles from './Reducer.module.scss';
44
import { ReduxTestCaseContext } from '../../../context/reducers/reduxTestCaseReducer';
55
import { deleteReducer, updateReducer } from '../../../context/actions/reduxTestCaseActions';
6-
import { updateHooksTestStatement } from '../../../context/actions/hooksTestCaseActions';
76

87
const closeIcon = require('../../../assets/images/close.png');
98
const dragIcon = require('../../../assets/images/drag-vertical.png');
@@ -118,33 +117,3 @@ const Reducer = ({ reducer, index }) => {
118117
};
119118

120119
export default Reducer;
121-
122-
{
123-
/* <div id={styles.reducerNameFlexBox}> */
124-
}
125-
{
126-
/* <div id={styles.reducerName}>
127-
<label htmlFor='typesFile'>Import Reducer From</label>
128-
<SearchInput
129-
options={Object.keys(filePathMap)}
130-
dispatch={dispatchToReduxTestCase}
131-
action={updateReducersFilePath}
132-
filePathMap={filePathMap}
133-
/>
134-
</div> */
135-
}
136-
{
137-
/* <div id={styles.reducerName}>
138-
<label htmlFor='typesFile'>Import Action Types From</label>
139-
<SearchInput
140-
options={Object.keys(filePathMap)}
141-
dispatch={dispatchToReduxTestCase}
142-
filePathMap={filePathMap}
143-
updateTypesFilePath={updateTypesFilePath}
144-
id={reducer.id}
145-
/>
146-
</div> */
147-
}
148-
{
149-
/* </div> */
150-
}

src/components/ReduxTestComponent/Thunk/Thunk.jsx

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import React, { useContext } from 'react';
22
import { Draggable } from 'react-beautiful-dnd';
33
import styles from './Thunk.module.scss';
4-
import { GlobalContext } from '../../../context/reducers/globalReducer';
54
import { ReduxTestCaseContext } from '../../../context/reducers/reduxTestCaseReducer';
65
import { deleteAsync, updateAsync } from '../../../context/actions/reduxTestCaseActions';
76

87
const closeIcon = require('../../../assets/images/close.png');
98
const dragIcon = require('../../../assets/images/drag-vertical.png');
10-
const questionIcon = require('../../../assets/images/help-circle.png');
119

1210
const Async = ({ async, index }) => {
13-
const [{ filePathMap }] = useContext(GlobalContext);
1411
const [, dispatchToReduxTestCase] = useContext(ReduxTestCaseContext);
1512

1613
const handleChangeAsyncFields = (e, field) => {
@@ -44,7 +41,7 @@ const Async = ({ async, index }) => {
4441
<input
4542
type='text'
4643
name='it'
47-
placeholder='eg/ should return expected action'
44+
placeholder='e.g. store should hold expected action'
4845
onChange={(e) => handleChangeAsyncFields(e, 'it')}
4946
/>
5047
</div>
@@ -73,7 +70,7 @@ const Async = ({ async, index }) => {
7370

7471
<div id={styles.groupFlexbox}>
7572
<div id={styles.labelInput}>
76-
<label htmlFor='expectedArg'>argument 1</label>
73+
<label htmlFor='expectedArg'>Argument 1</label>
7774
<div id={styles.inputFlexBox}>
7875
<input
7976
type='text'
@@ -101,12 +98,12 @@ const Async = ({ async, index }) => {
10198
</div>
10299
</div>
103100
<div id={styles.labelInput}>
104-
<label htmlFor='payloadKey'>argument 2</label>
101+
<label htmlFor='payloadKey'>Argument 2</label>
105102
<input
106103
type='text'
107104
id='payloadKey'
108105
onChange={(e) => handleChangeAsyncFields(e, 'payloadKey')}
109-
placeholder='e.g. todo'
106+
placeholder='e.g. id'
110107
/>
111108
</div>
112109
<div id={styles.dropdownWrapper}>
@@ -156,31 +153,6 @@ const Async = ({ async, index }) => {
156153
</div>
157154
</div>
158155
</div>
159-
160-
{async.responseType === 'object' ? (
161-
<div id={styles.groupFlexbox}>
162-
<div id={styles.labelInput}>
163-
<label htmlFor='responseKey'>Response Key</label>
164-
<div id={styles.inputFlexBox}>
165-
<input
166-
type='text'
167-
name='responseKey'
168-
onChange={(e) => handleChangeAsyncFields(e, 'responseKey')}
169-
/>
170-
</div>
171-
</div>
172-
<div id={styles.labelInput}>
173-
<label htmlFor='responseValue'>Response Value</label>
174-
<div id={styles.inputFlexBox}>
175-
<input
176-
type='text'
177-
name='responseValue'
178-
onChange={(e) => handleChangeAsyncFields(e, 'responseValue')}
179-
/>
180-
</div>
181-
</div>
182-
</div>
183-
) : null}
184156
</div>
185157
)}
186158
</Draggable>

src/components/SearchInput/SearchInput.jsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import React, { useState } from 'react';
1+
import React, { useState, useContext } from 'react';
22
import './SearchInput.scss';
3+
import { ReduxTestCaseContext } from '../../context/reducers/reduxTestCaseReducer';
34

45
const SearchInput = ({
56
dispatch,
@@ -16,6 +17,7 @@ const SearchInput = ({
1617
const [filteredOptions, setFilteredOptions] = useState([]);
1718
const [showOptions, setShowOptions] = useState(false);
1819
const [userInput, setUserInput] = useState('');
20+
const [, dispatchToReduxTestCase] = useContext(ReduxTestCaseContext);
1921

2022
const handleChange = (e) => {
2123
const input = e.currentTarget.value;
@@ -38,7 +40,13 @@ const SearchInput = ({
3840

3941
const selectedOption = e.target.type;
4042
const filePath = filePathMap[selectedOption] || '';
41-
if (updateTypesFilePath) dispatch(updateTypesFilePath(selectedOption, filePath, type)); //type));
43+
if (updateTypesFilePath) {
44+
if (dispatchToReduxTestCase === dispatch) {
45+
dispatch(updateTypesFilePath(selectedOption, filePath, 'reducer'));
46+
dispatch(updateTypesFilePath(selectedOption, filePath, 'async'));
47+
dispatch(updateTypesFilePath(selectedOption, filePath, 'action-creator'));
48+
} else dispatch(updateTypesFilePath(selectedOption, filePath, type));
49+
} //type));
4250
if (updateActionsFilePath) dispatch(updateActionsFilePath(selectedOption, filePath, type));
4351
if (action) dispatch(action(selectedOption, filePath));
4452
};
@@ -51,7 +59,13 @@ const SearchInput = ({
5159
const selectedOption = filteredOptions[activeOption];
5260
const filePath = filePathMap[selectedOption] || '';
5361
if (action) dispatch(action(selectedOption, filePath));
54-
if (updateTypesFilePath) dispatch(updateTypesFilePath(selectedOption, filePath, type)); //type));
62+
if (updateTypesFilePath) {
63+
if (dispatchToReduxTestCase === dispatch) {
64+
dispatch(updateTypesFilePath(selectedOption, filePath, 'reducer'));
65+
dispatch(updateTypesFilePath(selectedOption, filePath, 'async'));
66+
dispatch(updateTypesFilePath(selectedOption, filePath, 'action-creator'));
67+
} else dispatch(updateTypesFilePath(selectedOption, filePath, type));
68+
} //type));
5569
} else if (e.keyCode === 38) {
5670
if (activeOption === 0) {
5771
return;

src/components/TestCase/HooksTestStatements.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { useContext } from 'react';
2-
import Context from '../ReactHooksTestComponent/Context/Context';
32
import HookUpdates from '../ReactHooksTestComponent/HookUpdates/HookUpdates';
43
import { HooksTestCaseContext } from '../../context/reducers/hooksTestCaseReducer';
54
import { HooksStatements } from '../../utils/hooksTypes';

0 commit comments

Comments
 (0)