/*! * VisualEditor UserInterface MWWikitextStringTransferHandler tests. * * @copyright 2011-2017 Cite VisualEditor Team and others; see AUTHORS.txt * @license The MIT License (MIT); see LICENSE.txt */ window.MWWIKITEXT_MOCK_API = true; QUnit.module( 've.ui.MWWikitextStringTransferHandler (Cite)', QUnit.newMwEnvironment( { beforeEach: function () { // Mock XHR for mw.Api() this.server = window.MWWIKITEXT_MOCK_API ? this.sandbox.useFakeServer() : null; ve.test.utils.mwEnvironment.setup.call( this ); }, afterEach: ve.test.utils.mwEnvironment.teardown } ) ); /* Tests */ QUnit.test( 'convert', function ( assert ) { var i, cases = [ { msg: 'Simple reference', pasteString: 'Foo', pasteType: 'text/plain', parsoidResponse: '

[1]

' + '
    ' + '
  1. Foo
  2. ' + '
', annotations: [], expectedData: [ { 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: '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: '

[1]

' + '
    ' + '
  1. Reference list
  2. ' + '
', annotations: [], expectedData: [ { type: 'mwTransclusionInline', attributes: { mw: {}, originalMw: null } }, { type: '/mwTransclusionInline' }, { type: 'internalList' }, { type: '/internalList' } ] } ]; for ( i = 0; i < cases.length; i++ ) { 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 ); } } );