mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-24 05:38:52 +00:00
Check 'Select all' checkboxes on page load if all its checkboxes are checked
This means the code to set the initial value in the view template isn't needed.
This commit is contained in:
committed by
Filipe
parent
512394862b
commit
8e47949260
@@ -79,4 +79,35 @@ describe("SelectAllController", () => {
|
||||
expect(checkboxB.checked).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#connect", () => {
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = `
|
||||
<div data-controller="select-all">
|
||||
<input
|
||||
id="selectAllCheckbox"
|
||||
type="checkbox"
|
||||
data-action="change->select-all#toggleAll"
|
||||
data-select-all-target="all">
|
||||
<input
|
||||
id="checkboxA"
|
||||
type="checkbox"
|
||||
data-action="change->select-all#toggleCheckbox"
|
||||
data-select-all-target="checkbox"
|
||||
checked="checked">
|
||||
<input
|
||||
id="checkboxB"
|
||||
type="checkbox"
|
||||
data-action="change->select-all#toggleCheckbox"
|
||||
data-select-all-target="checkbox"
|
||||
checked="checked">
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
it("checks the select all checkbox on page load if all checkboxes are checked", () => {
|
||||
const selectAllCheckbox = document.getElementById("selectAllCheckbox");
|
||||
expect(selectAllCheckbox.checked).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user