File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ // Test 1: Should take in a function definition with 1 hook and return an object with the getter/setter
2+ // EXAMPLE INPUT FOR TEST
3+ /**
4+ * function UseStateHookTest() {
5+ * const [testCount, setTestCount] = useState(0);
6+ * return (
7+ * <div>
8+ * <p>You clicked this {useStateCount} times</p>
9+ * <button onClick={() => setTestCount(testCount + 1)}>+1</button>
10+ * <button onClick={() => setTestCount(testCount - 1)}>-1</button>
11+ * <hr />
12+ * </div>
13+ * );
14+ * }
15+ */
16+
17+ // EXPECTED RESULT of astParser(input)
18+ /**
19+ * {
20+ * _useState: "testCount",
21+ * _useState2: "setTestCount"
22+ * }
23+ */
24+
25+ // TEST 2: Should take in multiple function definitions with hooks and return an object with all 4 properties
26+ // TEST 3: Should ignore any non-hook definitions
27+ // Test 4: Should return an empty object if no hooks found
28+ // Test 5: Should throw an error if input is invalid javascript
You can’t perform that action at this time.
0 commit comments