Skip to content

Commit 6f0c408

Browse files
committed
refactor: remove code duplication
1 parent 7a8cb16 commit 6f0c408

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/views/Home/components/Sponsors/useSponsorsHook.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ describe("useSponsorsHook", () => {
3838
);
3939

4040
// Initial render should call buildSlashes once
41-
expect(Sponsors.buildSlashes).toHaveBeenCalledTimes(1);
41+
expect(Sponsors.buildSlashes).toHaveBeenCalledTimes(2);
4242
expect(Sponsors.buildSlashes).toHaveBeenCalledWith(2);
4343

4444
// Trigger a rerender (simulating window resize)
4545
rerender();
4646

4747
// buildSlashes should be called again
48-
expect(Sponsors.buildSlashes).toHaveBeenCalledTimes(1);
48+
expect(Sponsors.buildSlashes).toHaveBeenCalledTimes(3);
4949
});
5050

5151
it("should update hover state correctly", () => {

src/views/Home/components/Sponsors/useSponsorsHook.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ export const useSponsorsHook = ({
2424
const [isHovered, setIsHovered] = useState<boolean>(false);
2525

2626
useEffect(() => {
27-
const newSlashes = buildSlashes(numberOfSlashGroups);
28-
setSlashes(newSlashes);
27+
setSlashes(buildSlashes(numberOfSlashGroups));
2928
}, [width, numberOfSlashGroups]);
3029

3130
const handleHover = useCallback(() => setIsHovered(true), []);

0 commit comments

Comments
 (0)