Prevent adding empty tag

This commit is contained in:
Gaetan Craig-Riou
2025-04-15 15:31:31 +10:00
parent 31afdfd8c4
commit 1479be787b
2 changed files with 17 additions and 1 deletions

View File

@@ -103,6 +103,18 @@ describe("TagListInputController", () => {
expect(variant_add_tag.value).toBe("");
});
describe("with an empty new tag", () => {
it("doesn't add the tag", () => {
variant_add_tag.value = " ";
variant_add_tag.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" }));
const tagList = document.getElementsByClassName("tag-list")[0];
// 1 template + 3 tags + new tag (added in the beforeEach)
expect(tagList.childElementCount).toBe(5);
});
});
describe("when tag already exist", () => {
beforeEach(() => {
// Trying to add an existing tag