Skip to content

Commit

Permalink
EWPP-1830: Update pattern assertions and event rendering test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
22Alexandra committed Jan 5, 2022
1 parent e04c396 commit 07b3a9d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ protected function addRenderableOnlineType(array &$build, ContentEntityInterface
$build['#fields']['items'][] = [
'icon' => 'livestreaming',
'text' => $this->t('Live streaming available'),
'size' => 's',
];
}
}
Expand Down
9 changes: 9 additions & 0 deletions tests/src/Functional/ContentEventRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,11 @@ public function testEventRendering(): void {
[
'icon' => 'file',
'text' => 'Financing',
'size' => 's',
], [
'icon' => 'calendar',
'text' => '28 February 2020, 01:00',
'size' => 's',
],
],
];
Expand Down Expand Up @@ -271,9 +273,11 @@ public function testEventRendering(): void {
[
'icon' => 'file',
'text' => 'Financing',
'size' => 's',
], [
'icon' => 'calendar',
'text' => "28 February 2020, 01:00\n - 9 March 2020, 01:00",
'size' => 's',
],
],
];
Expand Down Expand Up @@ -328,6 +332,7 @@ public function testEventRendering(): void {
$icons_text_expected_values['items'][2] = [
'icon' => 'location',
'text' => '<Brussels>, Belgium',
'size' => 's',
];
$icons_text_assert->assertPattern($icons_text_expected_values, $details_list_content->getOuterHtml());

Expand Down Expand Up @@ -408,6 +413,7 @@ public function testEventRendering(): void {
$icons_text_expected_values['items'][3] = [
'icon' => 'livestreaming',
'text' => 'Live streaming available',
'size' => 's',
];
$icons_text_assert->assertPattern($icons_text_expected_values, $details_list_content->getOuterHtml());

Expand Down Expand Up @@ -672,12 +678,15 @@ public function testEventRendering(): void {
[
'icon' => 'file',
'text' => 'Financing',
'size' => 's',
], [
'icon' => 'calendar',
'text' => "28 February 2020, 01:00\n - 9 March 2020, 01:00",
'size' => 's',
], [
'icon' => 'livestreaming',
'text' => 'Live streaming available',
'size' => 's',
],
],
];
Expand Down
7 changes: 7 additions & 0 deletions tests/src/Kernel/EventRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public function testEventTeaser(): void {
[
'icon' => 'location',
'text' => 'Belgium',
'size' => 's',
],
],
]),
Expand Down Expand Up @@ -206,10 +207,12 @@ public function testEventTeaser(): void {
[
'icon' => 'location',
'text' => '<Brussels>, Belgium',
'size' => 's',
],
[
'icon' => 'livestreaming',
'text' => t('Live streaming available'),
'size' => 's',
],
],
]);
Expand All @@ -225,10 +228,12 @@ public function testEventTeaser(): void {
[
'icon' => 'location',
'text' => 'Online only',
'size' => 's',
],
[
'icon' => 'livestreaming',
'text' => t('Live streaming available'),
'size' => 's',
],
],
]);
Expand Down Expand Up @@ -280,10 +285,12 @@ public function testEventTeaser(): void {
[
'icon' => 'location',
'text' => '<Brussels>, Белгия',
'size' => 's',
],
[
'icon' => 'livestreaming',
'text' => t('Live streaming available'),
'size' => 's',
],
],
]);
Expand Down
3 changes: 2 additions & 1 deletion tests/src/PatternAssertions/IconsTextAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ protected function assertItems(array $expected_items, Crawler $crawler): void {
foreach ($expected_items as $index => $expected_item) {
$list_element = $list_elements->eq($index);
self::assertEquals($expected_item['text'], trim($list_element->text()));
$icon_element = $list_element->filter('svg.ecl-icon.ecl-icon--m.ecl-u-mr-s use');
$icon_selector = 'svg.ecl-icon.ecl-icon--' . $expected_item['size'] . '.ecl-u-mr-s use';
$icon_element = $list_element->filter($icon_selector);
$this::assertStringContainsString($expected_item['icon'], $icon_element->attr('xlink:href'));
}
}
Expand Down

0 comments on commit 07b3a9d

Please sign in to comment.