1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-12-25 00:11:36 +01:00

Add tests for hostname validation

This commit is contained in:
Aleksandr Gumroian 2022-01-28 17:45:42 +03:00
parent 7ceccd5222
commit 7ec1c46a63
No known key found for this signature in database
GPG Key ID: 9E77849C64F0A733

View File

@ -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. * This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information. * See /LICENSE for more information.
*/ */
import { import {
validateDomain,
validateDUID,
validateIPv4Address, validateIPv4Address,
validateIPv6Address, validateIPv6Address,
validateIPv6Prefix, validateIPv6Prefix,
validateDomain,
validateHostname,
validateDUID,
validateMAC, validateMAC,
} from "utils/validations"; } from "utils/validations";
@ -68,6 +69,15 @@ describe("Validation functions", () => {
expect(validateDomain(".")).not.toBe(undefined); 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", () => { it("validateDUID valid", () => {
expect(validateDUID("abcdefAB")).toBe(undefined); expect(validateDUID("abcdefAB")).toBe(undefined);
expect(validateDUID("ABCDEF12")).toBe(undefined); expect(validateDUID("ABCDEF12")).toBe(undefined);