generated from kawarimidoll/deno-dev-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
css_functions_test.ts
34 lines (31 loc) · 881 Bytes
/
css_functions_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
31
32
33
34
import { assert, assertEquals } from "./deps.ts";
import { getRandomInt, objectToCss } from "./css_functions.ts";
import { CssObject } from "./types.ts";
Deno.test("objectToCss", () => {
const cssObject: CssObject = {
"#main": {
width: "100%",
padding: "1rem 0.5rem",
},
".nav": {
display: "flex",
"justify-content": "space-around",
margin: "0 auto",
padding: "0.5rem",
width: "100%",
},
".nav>a": {
display: "block",
},
};
const css =
"#main{width:100%;padding:1rem 0.5rem}.nav{display:flex;justify-content:space-around;margin:0 auto;padding:0.5rem;width:100%}.nav>a{display:block}";
assertEquals(objectToCss(cssObject), css);
});
Deno.test("getRandomInt", () => {
// test 10 times
for (let i = 0; i < 10; i++) {
const num = getRandomInt(10);
assert(0 <= num && num <= 9);
}
});