feat: unit test - utils - validateLength

This commit is contained in:
Yaikawa
2021-10-29 21:22:58 +00:00
parent db560a2dbc
commit 3906079121
2 changed files with 45 additions and 0 deletions
+1
View File
@@ -1 +1,2 @@
import "./local/snowflake.ts";
import "./util/validateLength.ts";
+44
View File
@@ -0,0 +1,44 @@
import { validateLength } from "../../src/util/validate_length.ts";
import { assertEquals } from "../deps.ts";
Deno.test({
name: "[utils] Validate length is too low",
fn() {
assertEquals(validateLength("test", { min: 5 }), false);
},
});
Deno.test({
name: "[utils] Validate length is too high",
fn() {
assertEquals(validateLength("test", { max: 3 }), false);
},
});
Deno.test({
name: "[utils] Validate length is NOT just right in between.",
fn() {
assertEquals(validateLength("test", { min: 5, max: 3 }), false);
},
});
Deno.test({
name: "[utils] Validate length is NOT too low",
fn() {
assertEquals(validateLength("test", { min: 3 }), true);
},
});
Deno.test({
name: "[utils] Validate length is NOT too high",
fn() {
assertEquals(validateLength("test", { max: 5 }), true);
},
});
Deno.test({
name: "[utils] Validate length is just right in between.",
fn() {
assertEquals(validateLength("test", { min: 3, max: 6 }), true);
},
});