mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 23:46:05 -03:30
add useSelected tests for new functions
This commit is contained in:
@@ -19,6 +19,8 @@ describe('useSelected hook', () => {
|
|||||||
let isAllSelected;
|
let isAllSelected;
|
||||||
let handleSelect;
|
let handleSelect;
|
||||||
let setSelected;
|
let setSelected;
|
||||||
|
let selectAll;
|
||||||
|
let clearSelected;
|
||||||
|
|
||||||
test('should return expected initial values', () => {
|
test('should return expected initial values', () => {
|
||||||
testHook(() => {
|
testHook(() => {
|
||||||
@@ -72,4 +74,51 @@ describe('useSelected hook', () => {
|
|||||||
expect(selected).toEqual([]);
|
expect(selected).toEqual([]);
|
||||||
expect(isAllSelected).toEqual(false);
|
expect(isAllSelected).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should return selectAll', () => {
|
||||||
|
testHook(() => {
|
||||||
|
({
|
||||||
|
selected,
|
||||||
|
isAllSelected,
|
||||||
|
handleSelect,
|
||||||
|
setSelected,
|
||||||
|
selectAll,
|
||||||
|
} = useSelected(array));
|
||||||
|
});
|
||||||
|
|
||||||
|
act(() => {
|
||||||
|
selectAll(true);
|
||||||
|
});
|
||||||
|
expect(isAllSelected).toEqual(true);
|
||||||
|
expect(selected).toEqual(array);
|
||||||
|
|
||||||
|
act(() => {
|
||||||
|
selectAll(false);
|
||||||
|
});
|
||||||
|
expect(isAllSelected).toEqual(false);
|
||||||
|
expect(selected).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should return clearSelected', () => {
|
||||||
|
testHook(() => {
|
||||||
|
({
|
||||||
|
selected,
|
||||||
|
isAllSelected,
|
||||||
|
handleSelect,
|
||||||
|
setSelected,
|
||||||
|
selectAll,
|
||||||
|
clearSelected,
|
||||||
|
} = useSelected(array));
|
||||||
|
});
|
||||||
|
|
||||||
|
act(() => {
|
||||||
|
selectAll(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
act(() => {
|
||||||
|
clearSelected();
|
||||||
|
});
|
||||||
|
expect(isAllSelected).toEqual(false);
|
||||||
|
expect(selected).toEqual([]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user