mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 19:03:30 -05:00
Add tests for various different counter states
This commit is contained in:
@@ -610,7 +610,7 @@ describe('TemplateFolderForm', () => {
|
||||
|
||||
test("the content of the counter should reflect the selection", () => {
|
||||
|
||||
expect(visibleCounterText).toEqual('2 selected');
|
||||
expect(visibleCounterText).toEqual('1 template, 1 folder selected');
|
||||
|
||||
});
|
||||
|
||||
@@ -781,4 +781,70 @@ describe('TemplateFolderForm', () => {
|
||||
|
||||
});
|
||||
|
||||
describe("Additional selection counter scenarios", () => {
|
||||
|
||||
let templateFolderCheckboxes;
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
// start module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
templateFolderCheckboxes = getTemplateFolderCheckboxes();
|
||||
visibleCounterText = getVisibleCounter().textContent.trim();
|
||||
hiddenCounterText = getHiddenCounter().textContent.trim();
|
||||
|
||||
formControls = templateFolderForm.querySelector('#sticky_template_forms');
|
||||
|
||||
// reset sticky JS mocks called when the module starts
|
||||
resetStickyMocks();
|
||||
|
||||
});
|
||||
|
||||
afterEach(() => resetStickyMocks());
|
||||
|
||||
describe("When just templates are selected", () => {
|
||||
|
||||
test("the content of both visible and hidden counters should match", () => {
|
||||
|
||||
helpers.triggerEvent(templateFolderCheckboxes[1], 'click');
|
||||
helpers.triggerEvent(templateFolderCheckboxes[2], 'click');
|
||||
|
||||
expect(visibleCounterText).toEqual(hiddenCounterText);
|
||||
|
||||
});
|
||||
|
||||
test("the content of the counter should reflect the selection", () => {
|
||||
|
||||
helpers.triggerEvent(templateFolderCheckboxes[1], 'click');
|
||||
helpers.triggerEvent(templateFolderCheckboxes[2], 'click');
|
||||
|
||||
expect(visibleCounterText).toEqual('2 templates selected');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("When just folders are selected", () => {
|
||||
|
||||
test("the content of both visible and hidden counters should match", () => {
|
||||
|
||||
helpers.triggerEvent(templateFolderCheckboxes[0], 'click');
|
||||
|
||||
expect(visibleCounterText).toEqual(hiddenCounterText);
|
||||
|
||||
});
|
||||
|
||||
test("the content of the counter should reflect the selection", () => {
|
||||
|
||||
helpers.triggerEvent(templateFolderCheckboxes[0], 'click');
|
||||
|
||||
expect(visibleCounterText).toEqual('1 folder selected');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user