Nikerabbit has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382458 )

Change subject: Add a test case for multi-part template
......................................................................

Add a test case for multi-part template

Fixed order of actual and expected in assertion.

Change-Id: I16419c98a2506a8dc2e0f877c55ca48cab146716
TODO: Figure out why the gap parameter is dropped when it exists in sv too.
---
M test/translationunits/MWTemplate.test.js
M test/translationunits/MWTemplate.test.json
2 files changed, 122 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/58/382458/1

diff --git a/test/translationunits/MWTemplate.test.js 
b/test/translationunits/MWTemplate.test.js
index 198ac21..1269782 100644
--- a/test/translationunits/MWTemplate.test.js
+++ b/test/translationunits/MWTemplate.test.js
@@ -68,11 +68,11 @@
                        return translationunit.adapt( test.source ).then( ( 
adaptedNode ) => {
                                const actualDataCX = JSON.parse( 
adaptedNode.attributes[ 'data-cx' ] );
                                const expectedDataCX = test.result.attributes[ 
'data-cx' ];
-                               assert.deepEqual( expectedDataCX.adapted, 
actualDataCX.adapted, 'Adaptation status matches' );
+                               assert.deepEqual( actualDataCX.adapted, 
expectedDataCX.adapted, 'Adaptation status matches' );
 
                                const actualDataMW = JSON.parse( 
adaptedNode.attributes[ 'data-mw' ] );
                                const expectedDataMW = test.result.attributes[ 
'data-mw' ];
-                               assert.deepEqual( expectedDataMW, actualDataMW, 
'data-mw matches' );
+                               assert.deepEqual( actualDataMW, expectedDataMW, 
'data-mw matches' );
                        } );
                } );
        } );
diff --git a/test/translationunits/MWTemplate.test.json 
b/test/translationunits/MWTemplate.test.json
index d239b60..505d620 100644
--- a/test/translationunits/MWTemplate.test.json
+++ b/test/translationunits/MWTemplate.test.json
@@ -148,5 +148,125 @@
                                }
                        }
                }
+       },
+       {
+               "desc": "Multi-part template for columns",
+               "from": "en",
+               "to": "sv",
+               "source": {
+                       "attributes": {
+                               "id": "mwZw",
+                               "typeof": "mw:Transclusion",
+                               "data-mw": {
+                                       "parts": [
+                                               {
+                                                       "template": {
+                                                               "target": {
+                                                                       "wt": 
"col-begin",
+                                                                       "href": 
"./Template:Col-begin"
+                                                               },
+                                                               "params": {},
+                                                               "i": 0
+                                                       }
+                                               },
+                                               {
+                                                       "template": {
+                                                               "target": {
+                                                                       "wt": 
"col-break",
+                                                                       "href": 
"./Template:Col-break"
+                                                               },
+                                                               "params": {},
+                                                               "i": 1
+                                                       }
+                                               },
+                                               "\n* [[Arcosanti]]\n* 
[[Autonomous building]]\n* [[Bionic architecture]]\n* [[Dubai City Tower]]\n* 
[[Earthship]]\n* [[Megastructure]]\n* [[Proposed tall buildings and 
structures]]\n",
+                                               {
+                                                       "template": {
+                                                               "target": {
+                                                                       "wt": 
"col-break",
+                                                                       "href": 
"./Template:Col-break"
+                                                               },
+                                                               "params": {
+                                                                       "gap": {
+                                                                               
"wt": "4em"
+                                                                       }
+                                                               },
+                                                               "i": 2
+                                                       }
+                                               },
+                                               "\n* [[Shimizu Mega-City 
Pyramid]]\n* [[Underground city]]\n* [[Urban ecology]]\n* [[Vertical 
farming]]\n",
+                                               {
+                                                       "template": {
+                                                               "target": {
+                                                                       "wt": 
"col-end",
+                                                                       "href": 
"./Template:Col-end"
+                                                               },
+                                                               "params": {},
+                                                               "i": 3
+                                                       }
+                                               }
+                                       ]
+                               }
+                       }
+               },
+               "result": {
+                       "attributes": {
+                               "data-cx": [
+                                       {
+                                               "adapted": true
+                                       }
+                               ],
+                               "data-mw": {
+                                       "parts": [
+                                               {
+                                                       "template": {
+                                                               "target": {
+                                                                       "wt": 
"Col-begin",
+                                                                       "href": 
"./Mall:Col-begin"
+                                                               },
+                                                               "params": {},
+                                                               "i": 0
+                                                       }
+                                               },
+                                               {
+                                                       "template": {
+                                                               "target": {
+                                                                       "wt": 
"Col-break",
+                                                                       "href": 
"./Mall:Col-break"
+                                                               },
+                                                               "params": {},
+                                                               "i": 1
+                                                       }
+                                               },
+                                               "\n* [[Arcosanti]]\n* 
[[Autonomous building]]\n* [[Bionic architecture]]\n* [[Dubai City Tower]]\n* 
[[Earthship]]\n* [[Megastructure]]\n* [[Proposed tall buildings and 
structures]]\n",
+                                               {
+                                                       "template": {
+                                                               "target": {
+                                                                       "wt": 
"Col-break",
+                                                                       "href": 
"./Mall:Col-break"
+                                                               },
+                                                               "params": {
+                                                                       "gap": {
+                                                                               
"wt": "4em"
+                                                                       }
+                                                               },
+                                                               "i": 2
+                                                       }
+                                               },
+                                               "\n* [[Shimizu Mega-City 
Pyramid]]\n* [[Underground city]]\n* [[Urban ecology]]\n* [[Vertical 
farming]]\n",
+                                               {
+                                                       "template": {
+                                                               "target": {
+                                                                       "wt": 
"Col-end",
+                                                                       "href": 
"./Mall:Col-end"
+                                                               },
+                                                               "params": {},
+                                                               "i": 3
+                                                       }
+                                               }
+                                       ]
+                               }
+                       }
+               }
        }
 ]

-- 
To view, visit https://gerrit.wikimedia.org/r/382458
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I16419c98a2506a8dc2e0f877c55ca48cab146716
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to