diff options
Diffstat (limited to 'www/wiki/extensions/Translate/tests/qunit/ext.translate.special.pagemigration.test.js')
-rw-r--r-- | www/wiki/extensions/Translate/tests/qunit/ext.translate.special.pagemigration.test.js | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/www/wiki/extensions/Translate/tests/qunit/ext.translate.special.pagemigration.test.js b/www/wiki/extensions/Translate/tests/qunit/ext.translate.special.pagemigration.test.js index 724202aa..f2218ba2 100644 --- a/www/wiki/extensions/Translate/tests/qunit/ext.translate.special.pagemigration.test.js +++ b/www/wiki/extensions/Translate/tests/qunit/ext.translate.special.pagemigration.test.js @@ -1,10 +1,10 @@ /*! * Tests for ext.translate.special.pagemigration.js. * - * @license GPL-2.0+ + * @license GPL-2.0-or-later */ -( function ( $, mw ) { +( function () { 'use strict'; QUnit.module( 'ext.translate.special.pagemigration', QUnit.newMwEnvironment( { @@ -13,16 +13,15 @@ } } ) ); - QUnit.asyncTest( '-- Source units', function ( assert ) { - var data = '{ "query": { "messagecollection": [ { "key": "key_",' + + QUnit.test( '-- Source units', function ( assert ) { + var done, data = '{ "query": { "messagecollection": [ { "key": "key_",' + ' "definition": "definition_", "title": "title_" }, { "key": "key_1",' + ' "definition": "definition_1", "title": "title_1" } ] } }'; - QUnit.expect( 1 ); - + done = assert.async(); mw.translate.getSourceUnits( 'Help:Special pages' ).done( function ( sourceUnits ) { - assert.strictEqual( 1, sourceUnits.length, 'Source units retrieved' ); - QUnit.start(); + assert.strictEqual( sourceUnits.length, 1, 'Source units retrieved' ); + done(); } ); this.server.respond( function ( request ) { @@ -30,14 +29,13 @@ } ); } ); - QUnit.asyncTest( '-- Page does not exist', function ( assert ) { - var data = '{ "query": { "pages": { "-1": { "missing": "" } } } }'; - - QUnit.expect( 1 ); + QUnit.test( '-- Page does not exist', function ( assert ) { + var done, data = '{ "query": { "pages": { "-1": { "missing": "" } } } }'; + done = assert.async(); mw.translate.getFuzzyTimestamp( 'ugagagagagaga/uga' ).fail( function ( timestamp ) { - assert.strictEqual( undefined, timestamp, 'Page does not exist' ); - QUnit.start(); + assert.strictEqual( timestamp, undefined, 'Page does not exist' ); + done(); } ); this.server.respond( function ( request ) { @@ -45,15 +43,14 @@ } ); } ); - QUnit.asyncTest( '-- Fuzzy timestamp', function ( assert ) { - var data = '{ "query": { "pages": { "19563": {"revisions": ' + + QUnit.test( '-- Fuzzy timestamp', function ( assert ) { + var done, data = '{ "query": { "pages": { "19563": {"revisions": ' + '[ {"timestamp": "2014-02-18T20:59:58Z" }, { "timestamp": "t2" } ] } } } }'; - QUnit.expect( 1 ); - + done = assert.async(); mw.translate.getFuzzyTimestamp( 'Help:Special pages/fr' ).done( function ( timestamp ) { - assert.strictEqual( '2014-02-18T20:59:57.000Z', timestamp, 'Fuzzy timestamp retrieved' ); - QUnit.start(); + assert.strictEqual( timestamp, '2014-02-18T20:59:57.000Z', 'Fuzzy timestamp retrieved' ); + done(); } ); this.server.respond( function ( request ) { @@ -61,15 +58,15 @@ } ); } ); - QUnit.asyncTest( '-- Split translation page', function ( assert ) { - var data = '{ "query": { "pages": { "19563": { "revisions": ' + + QUnit.test( '-- Split translation page', function ( assert ) { + var done, data = '{ "query": { "pages": { "19563": { "revisions": ' + '[ { "*": "unit1\\n\\nunit2\\n\\nunit3" } ] } } } }'; - QUnit.expect( 1 ); + done = assert.async(); mw.translate.splitTranslationPage( '2014-02-18T20:59:57.000Z', 'Help:Special pages/fr' ) .done( function ( translationUnits ) { - assert.strictEqual( 3, translationUnits.length, 'Translation page split into units' ); - QUnit.start(); + assert.strictEqual( translationUnits.length, 3, 'Translation page split into units' ); + done(); } ); this.server.respond( function ( request ) { @@ -81,11 +78,9 @@ var sourceUnits, translationUnits1, result1, translationUnits2, result2; - QUnit.expect( 2 ); - - sourceUnits = [ { identifier: '1',definition: 'abc' }, { identifier: '2',definition: '==123==' }, - { identifier: '3',definition: 'pqr' }, { identifier: '4',definition: 'xyz' }, - { identifier: '5',definition: 'mno' }, { identifier: '6',definition: '==456==' } ]; + sourceUnits = [ { identifier: '1', definition: 'abc' }, { identifier: '2', definition: '==123==' }, + { identifier: '3', definition: 'pqr' }, { identifier: '4', definition: 'xyz' }, + { identifier: '5', definition: 'mno' }, { identifier: '6', definition: '==456==' } ]; translationUnits1 = [ '==123==', 'pqr', '==456==' ]; @@ -96,9 +91,9 @@ result2 = [ 'abc\nlmn\n', '==123==', 'pqr', '', '', '==456==' ]; translationUnits1 = mw.translate.alignHeaders( sourceUnits, translationUnits1 ); - assert.deepEqual( translationUnits1, result1, 'h2 headers aligned without merging' ); + assert.deepEqual( result1, translationUnits1, 'h2 headers aligned without merging' ); translationUnits2 = mw.translate.alignHeaders( sourceUnits, translationUnits2 ); - assert.deepEqual( translationUnits2, result2, 'h2 headers aligned with merging' ); + assert.deepEqual( result2, translationUnits2, 'h2 headers aligned with merging' ); } ); -}( jQuery, mediaWiki ) ); +}() ); |