Merge "Move out Cite-specific unit tests in WT transfer handler"

This commit is contained in:
jenkins-bot 2017-04-20 16:32:55 +00:00 committed by Gerrit Code Review
commit 6c4b3d68f7

View file

@ -16,7 +16,7 @@ QUnit.module( 've.ui.MWWikitextStringTransferHandler', QUnit.newMwEnvironment( {
/* Tests */
function runWikitextStringHandlerTest( assert, server, string, mimeType, expectedResponse, expectedData, annotations, assertDom, msg ) {
ve.test.utils.runWikitextStringHandlerTest = function ( assert, server, string, mimeType, expectedResponse, expectedData, annotations, assertDom, msg ) {
var handler, i, j, name,
done = assert.async(),
item = ve.ui.DataTransferItem.static.newFromString( string, mimeType ),
@ -80,7 +80,7 @@ function runWikitextStringHandlerTest( assert, server, string, mimeType, expecte
}
} ) ] );
}
}
};
QUnit.test( 'convert', function ( assert ) {
var i,
@ -227,77 +227,12 @@ QUnit.test( 'convert', function ( assert ) {
type: '/link/mwMagic'
}
]
},
{
msg: 'Simple reference',
pasteString: '<ref>Foo</ref>',
pasteType: 'text/plain',
parsoidResponse: '<p><span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw=\'{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}\'>[1]</span></p>' +
'<ol class="mw-references" typeof="mw:Extension/references" about="#mwt3" data-mw=\'{"name":"references","attrs":{},"autoGenerated":true}\'>' +
'<li about="#cite_note-1" id="cite_note-1">↑ <span id="mw-reference-text-cite_note-1" class="mw-reference-text">Foo</span></li>' +
'</ol>',
annotations: [],
expectedData: [
{ type: 'paragraph' },
{
type: 'mwReference',
attributes: {
mw: {
attrs: {},
body: {
id: 'mw-reference-text-cite_note-1'
},
name: 'ref'
},
contentsUsed: true,
listGroup: 'mwReference/',
listIndex: 0,
listKey: 'auto/0',
originalMw: '{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}',
refGroup: '',
refListItemId: 'mw-reference-text-cite_note-1'
}
},
{ type: '/mwReference' },
{ type: '/paragraph' },
{ type: 'internalList' },
{ type: 'internalItem' },
{ type: 'paragraph', internal: { generated: 'wrapper' } },
'F', 'o', 'o',
{ type: '/paragraph' },
{ type: '/internalItem' },
{ type: '/internalList' }
]
},
{
msg: 'Reference template with autoGenerated content',
pasteString: '{{reference}}',
pasteType: 'text/plain',
parsoidResponse: '<p><span typeof="mw:Transclusion">[1]</span></p>' +
'<ol class="mw-references" typeof="mw:Extension/references" about="#mwt3" data-mw=\'{"name":"references","attrs":{},"autoGenerated":true}\'>' +
'<li>Reference list</li>' +
'</ol>',
annotations: [],
expectedData: [
{
type: 'mwTransclusionInline',
attributes: {
mw: {},
originalMw: null
}
},
{
type: '/mwTransclusionInline'
},
{ type: 'internalList' },
{ type: '/internalList' }
]
}
];
QUnit.expect( cases.length * 2 );
for ( i = 0; i < cases.length; i++ ) {
runWikitextStringHandlerTest(
ve.test.utils.runWikitextStringHandlerTest(
assert, this.server, cases[ i ].pasteString, cases[ i ].pasteType, cases[ i ].parsoidResponse,
cases[ i ].expectedData, cases[ i ].annotations, cases[ i ].assertDom, cases[ i ].msg
);