DAT-4018 add test for europa theme enabled

This commit is contained in:
idradm 2016-03-29 12:57:07 +02:00
parent 508635c08f
commit 25dd444a80
2 changed files with 26 additions and 10 deletions

View file

@ -2,4 +2,4 @@
This template is linked with of mercury/front/templates/main/components/infobox-builder-item-wrapper.hbs
Changing this template requires modifying the other in mercury repo.
}}
<aside class="portable-infobox pi-background {{#isEuropaEnabled}} pi-europa{{/isEuropaEnabled}}{{#theme}} {{theme}}{{/theme}}{{#layout}} {{layout}}{{/layout}}">{{{content}}}</aside>
<aside class="portable-infobox pi-background{{#isEuropaEnabled}} pi-europa{{/isEuropaEnabled}}{{#theme}} {{theme}}{{/theme}}{{#layout}} {{layout}}{{/layout}}">{{{content}}}</aside>

View file

@ -27,7 +27,7 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
$mock = $this->getMockBuilder( 'Wikia\PortableInfobox\Helpers\PortableInfoboxRenderServiceHelper' )
->setMethods( [ 'isValidHeroDataItem', 'validateType', 'isWikiaMobile',
'createHorizontalGroupData', 'extendImageData' ] )
'createHorizontalGroupData', 'extendImageData' ] )
->getMock();
$mock->expects( $this->any() )
->method( 'isValidHeroDataItem' )
@ -53,7 +53,7 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
* @return string
*/
private function normalizeHTML( $html ) {
$DOM = new DOMDocument('1.0');
$DOM = new DOMDocument( '1.0' );
$DOM->formatOutput = true;
$DOM->preserveWhiteSpace = false;
$DOM->loadXML( $html );
@ -61,6 +61,22 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
return $DOM->saveXML();
}
public function testEuropaThemeEnabled() {
$wrapper = new \Wikia\Util\GlobalStateWrapper( [ 'wgEnablePortableInfoboxEuropaTheme' => true ] );
$infoboxRenderService = new PortableInfoboxRenderService();
$output = $wrapper->wrap( function () use ( $infoboxRenderService ) {
return $infoboxRenderService->renderInfobox(
[ [ 'type' => 'title', 'data' => [ 'value' => 'Test' ] ] ], '', '' );
} );
$expected = $this->normalizeHTML( '<aside class="portable-infobox pi-background pi-europa">
<h2 class="pi-item pi-item-spacing pi-title">Test</h2>
</aside>' );
$result = $this->normalizeHTML( $output );
$this->assertEquals( $expected, $result );
}
/**
* @param $input
* @param $expectedOutput
@ -73,7 +89,7 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
$infoboxRenderService = new PortableInfoboxRenderService();
$actualOutput = $infoboxRenderService->renderInfobox( $input, '', '' );
$expectedHtml = $this->normalizeHTML( $expectedOutput) ;
$expectedHtml = $this->normalizeHTML( $expectedOutput );
$actualHtml = $this->normalizeHTML( $actualOutput );
$this->assertEquals( $expectedHtml, $actualHtml, $description );
@ -82,7 +98,7 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
public function testRenderInfoboxDataProvider() {
return [
[
'input' => [],
'input' => [ ],
'output' => '',
'description' => 'Empty data should yield no infobox markup'
],
@ -287,7 +303,7 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
],
[
'type' => 'image',
'data' => []
'data' => [ ]
],
[
'type' => 'data',
@ -442,8 +458,8 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
'mockParams' => [
'createHorizontalGroupData' => [
'header' => 'Test header',
'labels' => ['test label', 'test label'],
'values' => ['test value', 'test value'],
'labels' => [ 'test label', 'test label' ],
'values' => [ 'test value', 'test value' ],
'renderLabels' => true
]
]
@ -490,8 +506,8 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
'description' => 'Infobox with horizontal group without header and labels',
'mockParams' => [
'createHorizontalGroupData' => [
'labels' => ['', ''],
'values' => ['test value', 'test value'],
'labels' => [ '', '' ],
'values' => [ 'test value', 'test value' ],
'renderLabels' => false
]
]