2017-04-20 16:11:00 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWWikitextStringTransferHandler tests.
|
|
|
|
*
|
2018-01-03 01:05:45 +00:00
|
|
|
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
|
2017-12-29 12:12:35 +00:00
|
|
|
* @license MIT
|
2017-04-20 16:11:00 +00:00
|
|
|
*/
|
2019-09-17 10:15:25 +00:00
|
|
|
|
2022-03-04 13:49:50 +00:00
|
|
|
QUnit.module( 've.ui.MWWikitextStringTransferHandler (Cite)', ve.test.utils.newMwEnvironment( {
|
2019-09-17 10:15:25 +00:00
|
|
|
beforeEach: function () {
|
|
|
|
// Mock XHR for mw.Api()
|
2020-06-09 10:29:34 +00:00
|
|
|
this.server = this.sandbox.useFakeServer();
|
2022-03-04 13:49:50 +00:00
|
|
|
}
|
2019-09-17 10:15:25 +00:00
|
|
|
} ) );
|
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
|
|
|
QUnit.test( 'convert', function ( assert ) {
|
2021-11-03 12:28:17 +00:00
|
|
|
var cases = [
|
|
|
|
{
|
|
|
|
msg: 'Simple reference',
|
|
|
|
pasteString: '<ref>Foo</ref>',
|
|
|
|
pasteType: 'text/plain',
|
|
|
|
parsoidResponse: '<p><span about="#mwt2" class="mw-ref reference" 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: {
|
|
|
|
listGroup: 'mwReference/',
|
|
|
|
listIndex: 0,
|
|
|
|
listKey: 'auto/0',
|
|
|
|
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: 'paragraph' },
|
|
|
|
{
|
|
|
|
type: 'mwTransclusionInline',
|
|
|
|
attributes: {
|
|
|
|
mw: {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: '/mwTransclusionInline'
|
|
|
|
},
|
|
|
|
{ type: '/paragraph' },
|
|
|
|
{ type: 'internalList' },
|
|
|
|
{ type: '/internalList' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
2019-09-17 10:15:25 +00:00
|
|
|
|
2021-11-03 12:28:17 +00:00
|
|
|
var server = this.server;
|
|
|
|
cases.forEach( function ( caseItem ) {
|
2019-09-17 10:15:25 +00:00
|
|
|
ve.test.utils.runWikitextStringHandlerTest(
|
2021-11-03 12:28:17 +00:00
|
|
|
assert, server, caseItem.pasteString, caseItem.pasteType,
|
|
|
|
caseItem.parsoidResponse, caseItem.expectedData, caseItem.annotations,
|
|
|
|
caseItem.assertDom, caseItem.msg
|
2019-09-17 10:15:25 +00:00
|
|
|
);
|
2021-11-03 12:28:17 +00:00
|
|
|
} );
|
2019-09-17 10:15:25 +00:00
|
|
|
} );
|