2 QUnit
.module( 'mediawiki.ForeignStructuredUpload', QUnit
.newMwEnvironment( {} ) );
4 QUnit
.test( 'Constructor check', function ( assert
) {
6 var upload
= new mw
.ForeignStructuredUpload();
8 assert
.ok( upload
, 'The ForeignUpload constructor is working.' );
9 assert
.ok( upload
.descriptions
, 'The descriptions array was initialized properly' );
10 assert
.ok( upload
.categories
, 'The categories array was initialized properly' );
13 QUnit
.test( 'getText', function ( assert
) {
16 var upload
= new mw
.ForeignStructuredUpload();
18 // Set basic information
19 upload
.addDescription( 'en', 'Test description one two three' );
20 upload
.addDescription( 'en-x-piglatin', 'Esttay escriptionday unway ootay eethray' );
21 upload
.setDate( '1776-07-04' );
22 upload
.addCategories( [ 'Test 1', 'Test 2' ] );
23 upload
.addCategories( [ 'Test 3' ] );
26 this.sandbox
.stub( upload
, 'getUser' ).returns( 'Test user' );
28 assert
.strictEqual( upload
.getText().trim(), '{{Information\n|description={{en|Test description one two three}}\n{{en-x-piglatin|Esttay escriptionday unway ootay eethray}}\n|date=1776-07-04\n|source=Test user\n|author=Test user\n}}\n\n\n\n[[Category:Test 1]]\n[[Category:Test 2]]\n[[Category:Test 3]]' );