From 7ec1c46a63c0dcea9d63c9ce0ac8b0568e5921a6 Mon Sep 17 00:00:00 2001 From: Aleksandr Gumroian Date: Fri, 28 Jan 2022 17:45:42 +0300 Subject: [PATCH] Add tests for hostname validation --- src/form/__tests__/validation.test.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/form/__tests__/validation.test.js b/src/form/__tests__/validation.test.js index 94de278..ac42e29 100644 --- a/src/form/__tests__/validation.test.js +++ b/src/form/__tests__/validation.test.js @@ -1,16 +1,17 @@ /* - * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/) + * Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/) * * This is free software, licensed under the GNU General Public License v3. * See /LICENSE for more information. */ import { - validateDomain, - validateDUID, validateIPv4Address, validateIPv6Address, validateIPv6Prefix, + validateDomain, + validateHostname, + validateDUID, validateMAC, } from "utils/validations"; @@ -68,6 +69,15 @@ describe("Validation functions", () => { expect(validateDomain(".")).not.toBe(undefined); }); + it("validateHostname valid", () => { + expect(validateHostname("new-android")).toBe(undefined); + expect(validateHostname("local")).toBe(undefined); + }); + it("validateHostname invalid", () => { + expect(validateHostname("-android")).not.toBe(undefined); + expect(validateHostname("local.")).not.toBe(undefined); + }); + it("validateDUID valid", () => { expect(validateDUID("abcdefAB")).toBe(undefined); expect(validateDUID("ABCDEF12")).toBe(undefined);