-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_test.ts
31 lines (23 loc) · 1.15 KB
/
mod_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { escapeHtml, isEscape, unescapeHtml, isUnescape, escapeSql } from "./mod.ts";
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
Deno.test("Case: Escape HTML String", () => {
assertEquals(escapeHtml("<script>sample</script>"), "<script>sample</script>");
});
Deno.test("Case: Not contain un-escape string", () => {
assertEquals(isEscape("Foo&bar"), true);
});
Deno.test("Case: Contain only un-escape string", () => {
assertEquals(isEscape(""awesome""), false);
});
Deno.test("Case: Contain un-escape and escape string", () => {
assertEquals(isEscape("Foo&bar "awesome""), true);
});
Deno.test("Case: Un-escape string.", () => {
assertEquals(unescapeHtml("&lt;script&gt;sample&lt;/script&gt;"), "<script>sample</script>");
});
Deno.test("Case: Is contain un-escape string.", () => {
assertEquals(isUnescape("&lt;script&gt;sample&lt;/script&gt;"), true);
});
Deno.test("Case: Escape SQL string.", () => {
assertEquals(escapeSql("insert into table_exp values('hi, my name's johnny.');"), "'insert into table_exp values(\\'hi, my name\\'s johnny.\\');'");
});