-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4775 from voxel51/merge/main-to-develop
Merge/main to develop
- Loading branch information
Showing
10 changed files
with
227 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { act, renderHook } from "@testing-library/react-hooks"; | ||
import { describe, expect, it } from "vitest"; | ||
import useRecords from "./useRecords"; | ||
|
||
describe("useRecords", () => { | ||
it("return new records when clear string changes", () => { | ||
const { result, rerender } = renderHook( | ||
(clear: string) => useRecords(clear), | ||
{ initialProps: "one" } | ||
); | ||
expect(result.current.size).toBe(0); | ||
|
||
act(() => { | ||
result.current.set("one", 1); | ||
}); | ||
|
||
expect(result.current.size).toBe(1); | ||
|
||
rerender("two"); | ||
|
||
expect(result.current.size).toBe(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useMemo } from "react"; | ||
|
||
export type Records = Map<string, number>; | ||
|
||
export default (clear: string) => { | ||
return useMemo(() => { | ||
clear; | ||
return new Map<string, number>(); | ||
}, [clear]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/packages/core/src/components/Grid/useSelectSample.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { addRange, removeRange } from "./useSelectSample"; | ||
|
||
describe("range selection tests", () => { | ||
it("adds a range, and includes selections without an index record", () => { | ||
const result = addRange( | ||
2, | ||
new Set(["0", "other"]), | ||
new Map([ | ||
["0", 0], | ||
["1", 1], | ||
["2", 2], | ||
]) | ||
); | ||
expect(result).toStrictEqual(new Set(["0", "1", "2", "other"])); | ||
}); | ||
|
||
it("removes a range, and includes selections without an index record", () => { | ||
const result = removeRange( | ||
1, | ||
new Set(["0", "1", "other"]), | ||
new Map([ | ||
["0", 0], | ||
["1", 1], | ||
]) | ||
); | ||
expect(result).toStrictEqual(new Set(["other"])); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.