From cc95aff900bb87477e7e3011abf657ba45d849d8 Mon Sep 17 00:00:00 2001 From: Eduardo Guzman-Diaz Date: Mon, 26 Jun 2023 07:16:39 -0400 Subject: [PATCH] Adding tests for isTagPresetNameValid (#4402) gondolin24 * Adding tests for isTagPresetNameValid * more generic tag names added more tests --------- Co-authored-by: Miodec --- backend/__tests__/utils/validation.spec.ts | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/backend/__tests__/utils/validation.spec.ts b/backend/__tests__/utils/validation.spec.ts index f649a0e2c..7821dac1b 100644 --- a/backend/__tests__/utils/validation.spec.ts +++ b/backend/__tests__/utils/validation.spec.ts @@ -1,6 +1,50 @@ import * as Validation from "../../src/utils/validation"; +import { isTagPresetNameValid } from "../../src/utils/validation"; describe("Validation", () => { + it("isTagPresetNameValid", () => { + const testCases = [ + { + name: "valid_name", + expected: true, + }, + { + name: "validname", + expected: true, + }, + { + name: "valid-name", + expected: true, + }, + { + name: "valid.name", + expected: true, + }, + { + name: "thistagnameistoolong", + expected: false, + }, + { + name: "", + expected: false, + }, + { + name: "invalid name", + expected: false, + }, + { + name: "invalid=name", + expected: false, + }, + ]; + + testCases.forEach((testCase) => { + expect(Validation.isTagPresetNameValid(testCase.name)).toBe( + testCase.expected + ); + }); + }); + it("inRange", () => { const testCases = [ {