Skip to content

Commit a6bc119

Browse files
committed
Update test of useSet
1 parent d4e671d commit a6bc119

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

tests/useSet.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ it('should init set and utils', () => {
1414
remove: expect.any(Function),
1515
toggle: expect.any(Function),
1616
reset: expect.any(Function),
17+
clear: expect.any(Function),
1718
});
1819
});
1920

@@ -145,10 +146,21 @@ it('should reset to initial set provided', () => {
145146
expect(result.current[0]).toEqual(new Set([1]));
146147
});
147148

149+
it('should be empty', () => {
150+
const { result } = setUp(new Set([1]));
151+
const [, utils] = result.current;
152+
153+
act(() => {
154+
utils.clear();
155+
});
156+
157+
expect(result.current[0]).toEqual(new Set([]));
158+
});
159+
148160
it('should memoized its utils methods', () => {
149161
const { result } = setUp(new Set(['a', 'b']));
150162
const [, utils] = result.current;
151-
const { add, remove, reset, toggle } = utils;
163+
const { add, remove, reset, clear, toggle } = utils;
152164

153165
act(() => {
154166
add('foo');
@@ -158,4 +170,5 @@ it('should memoized its utils methods', () => {
158170
expect(result.current[1].remove).toBe(remove);
159171
expect(result.current[1].toggle).toBe(toggle);
160172
expect(result.current[1].reset).toBe(reset);
173+
expect(result.current[1].clear).toBe(clear);
161174
});

0 commit comments

Comments
 (0)