deno.land / x / lume@v2.1.4 / tests / classname.test.ts

classname.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { assertStrictEquals as equals } from "../deps/assert.ts";import { attributes, className } from "../plugins/attributes.ts";
Deno.test("classname filter", () => { equals("one two", className("one", "two")); equals("one", className("one", null)); equals("one", className("one", undefined)); equals("one two", className(["one", "two"])); equals("one two", className(["one", "two"], "two")); equals( "one two", className(["one", "", false, null, undefined, 0, "two"], "two"), ); equals("one two", className({ one: true, two: 1 })); equals("one", className({ one: true, two: false })); equals("one two", className({ one: true, two: false }, "two")); equals( "one two", className({ one: true, two: false }, { one: false, two: true }), ); equals("one two", className([{ one: true, two: true }]));});
Deno.test("attributes filter", () => { equals("one two", attributes(["one", "two"])); equals('one="two"', attributes({ one: "two" })); equals("one", attributes({ one: true })); equals("two", attributes({ one: null, two: true })); equals( "one two", attributes([{ one: null, two: true }, { one: true }]), ); equals('foo=""bar""', attributes({ foo: '"bar"' })); equals('class="foo bar"', attributes({ class: "foo bar" })); equals('class="foo bar"', attributes({ class: ["foo bar"] })); equals('class="foo"', attributes({ class: ["foo", { bar: false }] })); equals( 'class="foo bar"', attributes({ class: ["foo", { bar: true }] }), ); equals( 'required class="foo bar"', attributes(["required", { class: ["foo", { bar: true }] }]), ); equals( 'required class="foo bar"', attributes(["required", { class: ["foo", { bar: true }] }]), ); equals( 'required class="foo bar"', attributes([{ required: true }, { class: ["foo", { bar: true }] }]), ); equals( 'required class="foo bar"', attributes([{ required: true, class: ["foo", { bar: true }] }]), ); equals( 'required class="foo bar"', attributes( ["required", { class: "foo" }, { class: ["bar", { other: false }] }], ), ); equals( 'required class="foo" title="bar"', attributes( ["required", { class: "foo" }, { id: "one", title: "bar" }], "required", "class", "title", ), ); equals( 'id="one"', attributes( ["required", { class: "foo" }, { id: "one", title: "bar" }], "id", ), );});
lume

Version Info

Tagged at
7 months ago