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