/** * MediaWiki CodeMirror tests. */ ( function ( $, mw ) { /** * Keys are the titles of the test cases. Each has an 'input' and the expected 'output'. * @type {Object} */ var config = mw.config.get( 'extCodeMirrorConfig' ), testCases = [ { title: 'p tags, extra closing tag', input: 'this is

content

', output: '' }, { title: 'indented table with caption and inline headings', input: ' ::{| class="wikitable"\n |+ Caption\n |-\n ! Uno !! Dos\n |-\n | Foo || Bar\n |}', output: '' }, { title: 'apostrophe before italic', input: 'plain l\'\'\'italic\'\'plain', output: '' }, { title: 'free external links', input: 'https://wikimedia.org [ftp://foo.bar FOO] //archive.org', output: '' }, { title: 'void tags', input: 'a
b
c a
b
c
d', output: '' }, { title: 'magic words', input: '__NOTOC__', output: '' }, { title: 'nowiki', input: '{{foo}}

{{{', output: '' }, { title: 'ref tag with cite web, extraneous curly braces', input: '{{cite web|2=foo}}}}', output: '' }, { title: 'template with params and parser function', input: '{{foo|1=bar|2={{{param|blah}}}|{{#if:{{{3|}}}|yes|no}}}}', output: '' }, { title: 'section headings', input: '== My section ==\nFoo bar\n=== Blah ===\nBaz', output: '' }, { title: 'bullets and numbering, with invalid leading spacing', input: '* bullet A\n* bullet B\n# one\n # two', output: '' }, { title: 'link with bold text', input: '[[Link title|\'\'\'bold link\'\'\']]', output: '' }, { title: 'horizontal rule', input: 'One\n----\nTwo', output: '' }, { title: 'comments', input: '', output: '' }, { title: 'signatures', input: 'my sig ~~~ ~~~~ ~~~~~~~', output: '' } ]; QUnit.module( 'ext.CodeMirror.mediawiki.test', QUnit.newMwEnvironment() ); /** * For some reason in QUnit we have to make the textarea, and supply it with the * wikitext prior to initializing CodeMirror. So this function will do this and * destroy CodeMirror after the test has completed, so that we have a clean slate * for the next iteration. * @param {string} wikitext * @param {Function} callback Ran after CodeMirror has been initialized. */ function setup( wikitext, callback ) { var $textarea = $( '