Skip to content

Commit 4d37e28

Browse files
authored
Merge pull request #58 from Luis-KM-Lo/hooksImport
Hooks import
2 parents dfcb285 + 8bf6fef commit 4d37e28

File tree

15 files changed

+306
-606
lines changed

15 files changed

+306
-606
lines changed

src/components/ReactHooksTestComponent/Context/Context.jsx

Lines changed: 205 additions & 196 deletions
Large diffs are not rendered by default.

src/components/ReactHooksTestComponent/HookRender/HookRender.jsx

Lines changed: 0 additions & 126 deletions
This file was deleted.

src/components/ReactHooksTestComponent/HookRender/HookRender.module.scss

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/components/ReactHooksTestComponent/HookUpdates/HookUpdates.jsx

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,6 @@ const HookUpdates = ({ hookUpdates, index }) => {
6161
<h3>Hooks</h3>
6262
</div>
6363
<div id={styles.hooksFlexBox}>
64-
{/* <div id={styles.hooks}>
65-
<label htmlFor='hookFile'>Import Hook From</label>
66-
<SearchInput
67-
options={Object.keys(filePathMap)}
68-
dispatch={dispatchToHooksTestCase}
69-
action={updateHooksFilePath}
70-
filePathMap={filePathMap}
71-
/>
72-
</div> */}
7364
<div id={styles.serverInput}>
7465
<label htmlFor='test-statement'>Test description</label>
7566
<div
@@ -84,7 +75,6 @@ const HookUpdates = ({ hookUpdates, index }) => {
8475
ref={testDescription}
8576
type='text'
8677
id={styles.testStatement}
87-
// value={hookUpdates.testName}
8878
onChange={(e) => handleChangeHookUpdatesFields(e, 'testName')}
8979
/>
9080
</div>
@@ -111,35 +101,22 @@ const HookUpdates = ({ hookUpdates, index }) => {
111101
/>
112102
</div>
113103
</div>
114-
{/* <div id={styles.cb}>
115-
<label htmlFor='callbackFunc'>Callback Function</label>
116-
<input
117-
type='text'
118-
id='callbackFunc'
119-
onChange={(e) => handleChangeHookUpdatesFields(e, 'callbackFunc')}
120-
placeholder='e.g. incrementCount'
121-
/>
122-
</div> */}
123104
{hookUpdates.callbackFunc.map((callbackFunc, i) => {
124105
return (
125106
<div id={styles.cbFlexBox}>
126-
<HooksCallback callbackFunc={callbackFunc} index={index} id={i} />{' '}
107+
<HooksCallback callbackFunc={callbackFunc} index={index} id={i} />
127108
</div>
128109
);
129-
})}{' '}
110+
})}
130111
<div className={styles.buttonsContainer}>
131-
<button
132-
// id={id}
133-
onClick={addCallbackHandleClick}
134-
className={styles.assertionButton}
135-
>
112+
<button onClick={addCallbackHandleClick} className={styles.assertionButton}>
136113
<i className='fas fa-plus'></i>
137114
Callback
138115
</button>
139116
</div>
140117
{hookUpdates.assertions.map((assertion, i) => {
141118
return <HooksAssertion assertion={assertion} index={index} id={i} />;
142-
})}{' '}
119+
})}
143120
<div className={styles.buttonsContainer} id={styles.stateFlexBox}>
144121
<button
145122
// id={id}

src/components/TestCase/HooksTestCase.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import HooksTestStatements from './HooksTestStatements';
1111
import { HooksStatements } from '../../utils/hooksTypes';
1212

1313
const HooksTestCase = () => {
14-
const [{ hooksTestStatement, hooksStatements }, dispatchToHooksTestCase] = useContext(
15-
HooksTestCaseContext
16-
);
14+
const [{ hooksStatements }, dispatchToHooksTestCase] = useContext(HooksTestCaseContext);
1715

1816
const testDescription = useRef<HTMLInputElement>(null);
1917

@@ -55,16 +53,15 @@ const HooksTestCase = () => {
5553
</div>
5654
<div id={styles.testMockSection}>
5755
<section id={styles.testCaseHeader}>
58-
<label htmlFor='test-statement'>
59-
Describe Block
60-
<br />
61-
<input
62-
ref={testDescription}
63-
type='text'
64-
id={styles.testStatement}
65-
onChange={handleUpdateHooksTestStatement}
66-
/>
67-
</label>
56+
Describe Block
57+
<br />
58+
<br />
59+
<input
60+
ref={testDescription}
61+
type='text'
62+
id={styles.testStatement}
63+
onChange={handleUpdateHooksTestStatement}
64+
/>
6865
</section>
6966
</div>
7067
<DragDropContext onDragEnd={onDragEnd}>

src/components/TestCase/HooksTestStatements.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ const HooksTestStatements = () => {
3737
{hImports}
3838
{hooksStatements.map((statement: HooksStatements, i: number) => {
3939
switch (statement.type) {
40-
case 'context':
41-
return <Context key={statement.id} context={statement} index={i} />;
42-
case 'hook-updates':
40+
case 'hooks':
4341
return <HookUpdates key={statement.id} hookUpdates={statement} index={i} />;
4442
default:
4543
return <></>;

src/components/TestCase/importOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function importOptionsSwitch(statements: statements[]) {
2222
case 'async':
2323
isAsyncOn = true;
2424
break;
25-
case 'hook-updates':
25+
case 'hooks':
2626
isHooksOn = true;
2727
break;
2828
default:

src/components/TestMenu/HooksTestMenu.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import {
77
toggleRightPanel,
88
} from '../../context/actions/globalActions';
99
import styles from './TestMenu.module.scss';
10-
import {
11-
addContexts,
12-
addHookUpdates,
13-
createNewHooksTest,
14-
} from '../../context/actions/hooksTestCaseActions';
10+
import { addHookUpdates, createNewHooksTest } from '../../context/actions/hooksTestCaseActions';
1511
import Modal from '../Modals/Modal';
1612
import useGenerateTest from '../../context/useGenerateTest';
1713
import { HooksTestCaseContext } from '../../context/reducers/hooksTestCaseReducer';
@@ -28,10 +24,6 @@ const HooksTestMenu = () => {
2824
const [{ projectFilePath, file, exportBool }, dispatchToGlobal] = useContext<any>(GlobalContext);
2925
const generateTest = useGenerateTest('hooks', projectFilePath);
3026

31-
const handleAddContexts = () => {
32-
dispatchToHooksTestCase(addContexts());
33-
};
34-
3527
const handleAddHookUpdates = () => {
3628
dispatchToHooksTestCase(addHookUpdates());
3729
};
@@ -82,9 +74,6 @@ const HooksTestMenu = () => {
8274
<button className='hookUpdatesButton' type='button' onClick={handleAddHookUpdates}>
8375
Hooks
8476
</button>
85-
<button className='contextButton' type='button' onClick={handleAddContexts}>
86-
Context
87-
</button>
8877
</div>
8978
</div>
9079
</div>

0 commit comments

Comments
 (0)