1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package org.devacfr.maven.skins.reflow.snippet; |
20 |
|
|
21 |
|
import org.devacfr.maven.skins.reflow.snippet.ComponentToken.Tag; |
22 |
|
import org.devacfr.maven.skins.reflow.snippet.ComponentToken.Type; |
23 |
|
import org.jsoup.nodes.Element; |
24 |
|
import org.junit.jupiter.api.Assertions; |
25 |
|
import org.junit.jupiter.api.Test; |
26 |
|
|
27 |
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
28 |
|
import static org.junit.jupiter.api.Assertions.assertNull; |
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (37) |
Complexity: 15 |
Complexity Density: 0,68 |
|
30 |
|
public class ComponentResolverTest { |
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
32 |
1 |
@Test... |
33 |
|
public void shouldBeStartWebComponent() { |
34 |
1 |
check("{{% component %}}", "component", Type.webComponent, Tag.start); |
35 |
|
} |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
37 |
1 |
@Test... |
38 |
|
public void shouldBeStartWebComponentWithAttributes() { |
39 |
1 |
check("{{% component style=\"width: 18rem;\" attr2=\"val\" %}}", "component", Type.webComponent, Tag.start); |
40 |
|
} |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
42 |
1 |
@Test... |
43 |
|
public void shouldBeStartWebComponentWithAttributesLeftAndRightDoubleQuote() { |
44 |
1 |
check("{{% component style=“width: 18rem;” attr2=“val” %}}", "component", Type.webComponent, Tag.start); |
45 |
|
} |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
47 |
1 |
@Test... |
48 |
|
public void shouldBeStartWebComponentWithAttributeWithoutValue() { |
49 |
1 |
check("{{% component pill %}}", "component", Type.webComponent, Tag.start); |
50 |
|
} |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
52 |
1 |
@Test... |
53 |
|
public void shouldBeStartWebComponentWithNumberAttributes() { |
54 |
1 |
check("{{% component length=\"120\" %}}", "component", Type.webComponent, Tag.start); |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
57 |
1 |
@Test... |
58 |
|
public void shouldBeEndWebComponent() { |
59 |
1 |
check("{{% /component %}}", "component", Type.webComponent, Tag.end); |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
62 |
1 |
@Test... |
63 |
|
public void shouldBeEmptyWebComponent() { |
64 |
1 |
check("{{% component /%}}", "component", Type.webComponent, Tag.empty); |
65 |
|
} |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
67 |
1 |
@Test... |
68 |
|
public void shouldBeStartShortcode() { |
69 |
1 |
check("{{< component >}}", "component", Type.shortcode, Tag.start); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
72 |
1 |
@Test... |
73 |
|
public void shouldBeEndShortcode() { |
74 |
1 |
check("{{< /component >}}", "component", Type.shortcode, Tag.end); |
75 |
|
} |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
77 |
1 |
@Test... |
78 |
|
public void shouldBeEmptyShortcode() { |
79 |
1 |
check("{{< component />}}", "component", Type.shortcode, Tag.empty); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1PASS
|
|
82 |
1 |
@Test... |
83 |
|
public void shouldFailedOnMalformed() { |
84 |
1 |
Assertions.assertThrows(RuntimeException.class, () -> { |
85 |
1 |
new ComponentResolver().create(new Element("p").text("{{% /component /%}}")); |
86 |
|
}); |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
89 |
1 |
@Test... |
90 |
|
public void shouldFailedUnknownComponent() { |
91 |
1 |
assertNull(new ComponentResolver().create(new Element("p").text("{{- /component -}}"))); |
92 |
|
} |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
94 |
1 |
@Test... |
95 |
|
public void shouldElementStartWebComponentContainingAttributes() { |
96 |
1 |
check("{{% component attr=\"value\" attr1=\"value1\" %}}", "component", Type.webComponent, Tag.start); |
97 |
|
} |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1PASS
|
|
99 |
1 |
@Test... |
100 |
|
public void shouldContainSnippetComponent() { |
101 |
1 |
assertEquals(true, |
102 |
|
ComponentResolver.hasIncludedSnippetComponent( |
103 |
|
new Element("body").append("<test webcomponent class=\"cl\"></test>"))); |
104 |
1 |
assertEquals(true, |
105 |
|
ComponentResolver |
106 |
|
.hasIncludedSnippetComponent(new Element("body").append("<test shortcode class=\"cl\"></test>"))); |
107 |
1 |
assertEquals(false, ComponentResolver.hasIncludedSnippetComponent(new Element("body").append("<test></test>"))); |
108 |
|
} |
109 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
110 |
11 |
private ComponentToken check(final String text, final String name, final Type type, final Tag state) {... |
111 |
11 |
final ComponentToken element = new ComponentResolver().create(new Element("p").text(text)); |
112 |
11 |
assertEquals(name, element.name()); |
113 |
11 |
assertEquals(type, element.type()); |
114 |
11 |
assertEquals(state, element.tag()); |
115 |
11 |
return element; |
116 |
|
} |
117 |
|
} |