mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 03:35:53 +00:00
XW-2444: adding tests
This commit is contained in:
parent
39ccd95df9
commit
c5c1a2c071
|
@ -176,10 +176,6 @@ class PortableInfoboxRenderService extends WikiaService {
|
|||
$backgroundColor = empty( $accentColor ) ? '' : "background-color:{$accentColor};";
|
||||
$color = empty( $accentColorText ) ? '' : "color:{$accentColorText};";
|
||||
|
||||
if ( empty( $backgroundColor ) && empty( $color ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return "style={$backgroundColor}{$color}";
|
||||
return "{$backgroundColor}{$color}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
<h2 class="pi-item pi-header pi-secondary-font pi-item-spacing pi-secondary-background" {{inlineStyles}}>{{{value}}}</h2>
|
||||
<h2 class="pi-item pi-header pi-secondary-font pi-item-spacing pi-secondary-background" {{#inlineStyles}}style="{{inlineStyles}}"{{/inlineStyles}}>{{{value}}}</h2>
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
This template is linked with of mercury/front/templates/main/components/infobox-builder-item-title.hbs
|
||||
Changing this template requires modifying the other in mercury repo.
|
||||
}}
|
||||
<h2 class="pi-item pi-item-spacing pi-title" {{inlineStyles}}>{{{value}}}</h2>
|
||||
<h2 class="pi-item pi-item-spacing pi-title" {{#inlineStyles}}style="{{inlineStyles}}"{{/inlineStyles}}>{{{value}}}</h2>
|
||||
|
|
|
@ -79,11 +79,11 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
|
|||
* @param $mockParams
|
||||
* @dataProvider testRenderInfoboxDataProvider
|
||||
*/
|
||||
public function testRenderInfobox( $input, $expectedOutput, $description, $mockParams ) {
|
||||
public function testRenderInfobox( $input, $expectedOutput, $description, $mockParams, $accentColor, $accentColorText ) {
|
||||
$this->mockInfoboxRenderServiceHelper( $mockParams );
|
||||
|
||||
$infoboxRenderService = new PortableInfoboxRenderService();
|
||||
$actualOutput = $infoboxRenderService->renderInfobox( $input, '', '', '', '' );
|
||||
$actualOutput = $infoboxRenderService->renderInfobox( $input, '', '', $accentColor, $accentColorText );
|
||||
$expectedHtml = $this->normalizeHTML( $expectedOutput );
|
||||
$actualHtml = $this->normalizeHTML( $actualOutput );
|
||||
|
||||
|
@ -111,6 +111,23 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
|
|||
</aside>',
|
||||
'description' => 'Only title'
|
||||
],
|
||||
[
|
||||
'input' => [
|
||||
[
|
||||
'type' => 'title',
|
||||
'data' => [
|
||||
'value' => 'Test Title'
|
||||
]
|
||||
]
|
||||
],
|
||||
'output' => '<aside class="portable-infobox pi-background">
|
||||
<h2 class="pi-item pi-item-spacing pi-title" style="background-color:#FFF;color:#000;">Test Title</h2>
|
||||
</aside>',
|
||||
'description' => 'Only title with custom colors',
|
||||
'mockParams' => [],
|
||||
'accentColor' => '#FFF',
|
||||
'accentColorText' => '#000'
|
||||
],
|
||||
[
|
||||
'input' => [
|
||||
[
|
||||
|
@ -397,6 +414,61 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
|
|||
</aside>',
|
||||
'description' => 'Infobox with title, group with header and two key-value pairs'
|
||||
],
|
||||
[
|
||||
'input' => [
|
||||
[
|
||||
'type' => 'title',
|
||||
'data' => [
|
||||
'value' => 'Test Title'
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => 'group',
|
||||
'data' => [
|
||||
'value' => [
|
||||
[
|
||||
'type' => 'header',
|
||||
'data' => [
|
||||
'value' => 'Test Header'
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => 'data',
|
||||
'data' => [
|
||||
'label' => 'test label',
|
||||
'value' => 'test value'
|
||||
]
|
||||
],
|
||||
[
|
||||
'type' => 'data',
|
||||
'data' => [
|
||||
'label' => 'test label',
|
||||
'value' => 'test value'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'output' => '<aside class="portable-infobox pi-background">
|
||||
<h2 class="pi-item pi-item-spacing pi-title" style="background-color:#FFF;color:#000;">Test Title</h2>
|
||||
<section class="pi-item pi-group pi-border-color">
|
||||
<h2 class="pi-item pi-header pi-secondary-font pi-item-spacing pi-secondary-background" style="background-color:#FFF;color:#000;">Test Header</h2>
|
||||
<div class="pi-item pi-data pi-item-spacing pi-border-color">
|
||||
<h3 class="pi-data-label pi-secondary-font">test label</h3>
|
||||
<div class="pi-data-value pi-font">test value</div>
|
||||
</div>
|
||||
<div class="pi-item pi-data pi-item-spacing pi-border-color">
|
||||
<h3 class="pi-data-label pi-secondary-font">test label</h3>
|
||||
<div class="pi-data-value pi-font">test value</div>
|
||||
</div>
|
||||
</section>
|
||||
</aside>',
|
||||
'description' => 'Infobox with title, group with header and two key-value pairs, custom accent color and accent text color',
|
||||
'mockParams' => [],
|
||||
'accentColor' => '#FFF',
|
||||
'accentColorText' => '#000'
|
||||
],
|
||||
[
|
||||
'input' => [
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue