Bmansurov has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/183538

Change subject: Apply jscs to some module test file
......................................................................

Apply jscs to some module test file

Modules include:
* editor

Ignore jsDoc rule

Bug: T85876
Change-Id: Icd4ec82ca51000f2695dc22984758d5b25f5e6ec
---
M tests/qunit/modules/editor/test_EditorApi.js
M tests/qunit/modules/editor/test_EditorOverlay.js
2 files changed, 329 insertions(+), 166 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/38/183538/1

diff --git a/tests/qunit/modules/editor/test_EditorApi.js 
b/tests/qunit/modules/editor/test_EditorApi.js
index 96e16ce..c29b4ba 100644
--- a/tests/qunit/modules/editor/test_EditorApi.js
+++ b/tests/qunit/modules/editor/test_EditorApi.js
@@ -1,18 +1,19 @@
+//jscs:disable jsDoc
 ( function ( M, $ ) {
 
        var EditorApi = M.require( 'modules/editor/EditorApi' );
 
        QUnit.module( 'MobileFrontend modules/editor/EditorApi', {
-               setup: function() {
+               setup: function () {
                        this.spy = this.sandbox.stub( EditorApi.prototype, 
'get' ).returns( $.Deferred().resolve( {
-                               "query": {
-                                       "pages": {
-                                               "1": {
-                                                       "revisions": [
+                               query: {
+                                       pages: {
+                                               1: {
+                                                       revisions: [
                                                                {
-                                                               "timestamp": 
"2013-05-15T00:30:26Z",
-                                                               "*": "section"
-                                                       }
+                                                                       
timestamp: '2013-05-15T00:30:26Z',
+                                                                       '*': 
'section'
+                                                               }
                                                        ]
                                                }
                                        }
@@ -22,61 +23,83 @@
                }
        } );
 
-       QUnit.test( '#getContent (no section)', 1, function( assert ) {
-               var editorApi = new EditorApi( { title: 'MediaWiki:Test.css' } 
);
+       QUnit.test( '#getContent (no section)', 1, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'MediaWiki:Test.css'
+               } );
 
                editorApi.getContent();
                assert.ok( this.spy.calledWith( {
-                               action: 'query',
-                               prop: 'revisions',
-                               rvprop: [ 'content', 'timestamp' ],
-                               titles: 'MediaWiki:Test.css'
-                       } ), 'rvsection not passed to api request' );
+                       action: 'query',
+                       prop: 'revisions',
+                       rvprop: [ 'content', 'timestamp' ],
+                       titles: 'MediaWiki:Test.css'
+               } ), 'rvsection not passed to api request' );
        } );
 
-       QUnit.test( '#getContent', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
);
+       QUnit.test( '#getContent', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'test',
+                       sectionId: 1
+               } );
 
-               editorApi.getContent().done( function( resp ) {
+               editorApi.getContent().done( function ( resp ) {
                        assert.strictEqual( resp, 'section', 'return section 
content' );
                } );
                editorApi.getContent();
                assert.ok( editorApi.get.calledOnce, 'cache content' );
        } );
 
-       QUnit.test( '#getContent, new page', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', isNewPage: true 
} );
+       QUnit.test( '#getContent, new page', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'test',
+                       isNewPage: true
+               } );
 
-               editorApi.getContent().done( function( resp ) {
+               editorApi.getContent().done( function ( resp ) {
                        assert.strictEqual( resp, '', 'return empty section' );
                } );
-               assert.ok( !editorApi.get.called, "don't try to retrieve 
content using API" );
+               assert.ok( !editorApi.get.called, 'don\'t try to retrieve 
content using API' );
        } );
 
-       QUnit.test( '#getContent, missing section', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
), doneSpy = this.sandbox.spy();
+       QUnit.test( '#getContent, missing section', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'test',
+                       sectionId: 1
+               } ), doneSpy = this.sandbox.spy();
 
                EditorApi.prototype.get.restore();
                this.sandbox.stub( EditorApi.prototype, 'get' ).returns( 
$.Deferred().resolve( {
-                       "error": { "code": "rvnosuchsection" }
+                       error: {
+                               code: 'rvnosuchsection'
+                       }
                } ) );
 
-               editorApi.getContent().done( doneSpy ).fail( function( error ) {
-                       assert.strictEqual( error, 'rvnosuchsection', "return 
error code" );
+               editorApi.getContent().done( doneSpy ).fail( function ( error ) 
{
+                       assert.strictEqual( error, 'rvnosuchsection', 'return 
error code' );
                } );
-               assert.ok( !doneSpy.called, "don't call done" );
+               assert.ok( !doneSpy.called, 'don\'t call done' );
        } );
 
-       QUnit.test( '#save, success', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
);
+       QUnit.test( '#save, success', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'test',
+                       sectionId: 1
+               } );
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve(
-                       { edit: { result: 'Success' } }
+                       {
+                               edit: {
+                                       result: 'Success'
+                               }
+                       }
                ) );
 
                editorApi.getContent();
                editorApi.setContent( 'section 1' );
-               editorApi.save( { summary: 'summary' } ).done( function() {
+               editorApi.save( {
+                       summary: 'summary'
+               } ).done( function () {
                        assert.ok( editorApi.post.calledWith( {
                                action: 'edit',
                                title: 'test',
@@ -93,16 +116,25 @@
                assert.strictEqual( editorApi.hasChanged, false, 'reset 
hasChanged' );
        } );
 
-       QUnit.test( '#save, new page', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'Talk:test', isNewPage: 
true } );
+       QUnit.test( '#save, new page', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'Talk:test',
+                       isNewPage: true
+               } );
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve(
-                       { edit: { result: 'Success' } }
+                       {
+                               edit: {
+                                       result: 'Success'
+                               }
+                       }
                ) );
 
                editorApi.getContent();
                editorApi.setContent( 'section 0' );
-               editorApi.save( { summary: 'summary' } ).done( function() {
+               editorApi.save( {
+                       summary: 'summary'
+               } ).done( function () {
                        assert.ok( editorApi.post.calledWith( {
                                action: 'edit',
                                title: 'Talk:test',
@@ -118,15 +150,23 @@
                assert.strictEqual( editorApi.hasChanged, false, 'reset 
hasChanged' );
        } );
 
-       QUnit.test( '#save, after #setPrependText', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test' } );
+       QUnit.test( '#save, after #setPrependText', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'test'
+               } );
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve(
-                       { edit: { result: 'Success' } }
+                       {
+                               edit: {
+                                       result: 'Success'
+                               }
+                       }
                ) );
 
                editorApi.setPrependText( 'abc' );
-               editorApi.save( { summary: 'summary' } ).done( function() {
+               editorApi.save( {
+                       summary: 'summary'
+               } ).done( function () {
                        assert.ok( editorApi.post.calledWith( {
                                action: 'edit',
                                title: 'test',
@@ -142,16 +182,27 @@
                assert.strictEqual( editorApi.hasChanged, false, 'reset 
hasChanged' );
        } );
 
-       QUnit.test( '#save, submit CAPTCHA', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
);
+       QUnit.test( '#save, submit CAPTCHA', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'test',
+                       sectionId: 1
+               } );
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve(
-                       { edit: { result: 'Success' } }
+                       {
+                               edit: {
+                                       result: 'Success'
+                               }
+                       }
                ) );
 
                editorApi.getContent();
                editorApi.setContent( 'section 1' );
-               editorApi.save( { summary: 'summary', captchaId: 123, 
captchaWord: 'abc' } ).done( function() {
+               editorApi.save( {
+                       summary: 'summary',
+                       captchaId: 123,
+                       captchaWord: 'abc'
+               } ).done( function () {
                        assert.ok( editorApi.post.calledWith( {
                                action: 'edit',
                                title: 'test',
@@ -168,9 +219,13 @@
                assert.strictEqual( editorApi.hasChanged, false, 'reset 
hasChanged' );
        } );
 
-       QUnit.test( '#save, request failure', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
),
-                       doneSpy = this.sandbox.spy(), failSpy = 
this.sandbox.spy();
+       QUnit.test( '#save, request failure', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                               title: 'test',
+                               sectionId: 1
+                       } ),
+                       doneSpy = this.sandbox.spy(),
+                       failSpy = this.sandbox.spy();
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().reject() );
 
@@ -179,16 +234,27 @@
 
                editorApi.save().done( doneSpy ).fail( failSpy );
 
-               assert.ok( failSpy.calledWith( { type: 'error', details: 'http' 
} ), "call fail" );
-               assert.ok( !doneSpy.called, "don't call done" );
+               assert.ok( failSpy.calledWith( {
+                       type: 'error',
+                       details: 'http'
+               } ), 'call fail' );
+               assert.ok( !doneSpy.called, 'don\'t call done' );
        } );
 
-       QUnit.test( '#save, API failure', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
),
-                       doneSpy = this.sandbox.spy(), failSpy = 
this.sandbox.spy();
+       QUnit.test( '#save, API failure', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                               title: 'test',
+                               sectionId: 1
+                       } ),
+                       doneSpy = this.sandbox.spy(),
+                       failSpy = this.sandbox.spy();
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve(
-                       { error: { code: 'error code' } }
+                       {
+                               error: {
+                                       code: 'error code'
+                               }
+                       }
                ) );
 
                editorApi.getContent();
@@ -196,19 +262,26 @@
 
                editorApi.save().done( doneSpy ).fail( failSpy );
 
-               assert.ok( failSpy.calledWith( { type: 'error', details: 'error 
code' } ), "call fail" );
-               assert.ok( !doneSpy.called, "don't call done" );
+               assert.ok( failSpy.calledWith( {
+                       type: 'error',
+                       details: 'error code'
+               } ), 'call fail' );
+               assert.ok( !doneSpy.called, 'don\'t call done' );
        } );
 
-       QUnit.test( '#save, CAPTCHA response with image URL', 2, function( 
assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
),
+       QUnit.test( '#save, CAPTCHA response with image URL', 2, function ( 
assert ) {
+               var editorApi = new EditorApi( {
+                               title: 'test',
+                               sectionId: 1
+                       } ),
                        captcha = {
-                               type: "image",
-                               mime: "image/png",
-                               id: "1852528679",
-                               url: 
"/w/index.php?title=Especial:Captcha/image&wpCaptchaId=1852528679"
+                               type: 'image',
+                               mime: 'image/png',
+                               id: '1852528679',
+                               url: 
'/w/index.php?title=Especial:Captcha/image&wpCaptchaId=1852528679'
                        },
-                       doneSpy = this.sandbox.spy(), failSpy = 
this.sandbox.spy();
+                       doneSpy = this.sandbox.spy(),
+                       failSpy = this.sandbox.spy();
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {
                        edit: {
@@ -222,20 +295,27 @@
 
                editorApi.save().done( doneSpy ).fail( failSpy );
 
-               assert.ok( failSpy.calledWith( { type: 'captcha', details: 
captcha } ), "call fail" );
-               assert.ok( !doneSpy.called, "don't call done" );
+               assert.ok( failSpy.calledWith( {
+                       type: 'captcha',
+                       details: captcha
+               } ), 'call fail' );
+               assert.ok( !doneSpy.called, 'don\'t call done' );
        } );
 
-       QUnit.test( '#save, AbuseFilter warning', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
),
-                       doneSpy = this.sandbox.spy(), failSpy = 
this.sandbox.spy();
+       QUnit.test( '#save, AbuseFilter warning', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                               title: 'test',
+                               sectionId: 1
+                       } ),
+                       doneSpy = this.sandbox.spy(),
+                       failSpy = this.sandbox.spy();
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {
                        edit: {
-                               code: "abusefilter-warning-usuwanie-tekstu",
-                               info: "Hit AbuseFilter: Usuwanie du\u017cej 
ilo\u015bci tekstu",
-                               warning: "horrible desktop-formatted message",
-                               result: "Failure"
+                               code: 'abusefilter-warning-usuwanie-tekstu',
+                               info: 'Hit AbuseFilter: Usuwanie du\u017cej 
ilo\u015bci tekstu',
+                               warning: 'horrible desktop-formatted message',
+                               result: 'Failure'
                        }
                } ) );
 
@@ -248,22 +328,26 @@
                        type: 'abusefilter',
                        details: {
                                type: 'warning',
-                               message: "horrible desktop-formatted message"
+                               message: 'horrible desktop-formatted message'
                        }
-               } ), "call fail with type and message" );
-               assert.ok( !doneSpy.called, "don't call done" );
+               } ), 'call fail with type and message' );
+               assert.ok( !doneSpy.called, 'don\'t call done' );
        } );
 
-       QUnit.test( '#save, AbuseFilter disallow', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
),
-                       doneSpy = this.sandbox.spy(), failSpy = 
this.sandbox.spy();
+       QUnit.test( '#save, AbuseFilter disallow', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                               title: 'test',
+                               sectionId: 1
+                       } ),
+                       doneSpy = this.sandbox.spy(),
+                       failSpy = this.sandbox.spy();
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {
                        edit: {
-                               code: "abusefilter-disallow",
-                               info: "Scary filter",
-                               warning: "horrible desktop-formatted message",
-                               result: "Failure"
+                               code: 'abusefilter-disallow',
+                               info: 'Scary filter',
+                               warning: 'horrible desktop-formatted message',
+                               result: 'Failure'
                        }
                } ) );
 
@@ -276,22 +360,26 @@
                        type: 'abusefilter',
                        details: {
                                type: 'disallow',
-                               message: "horrible desktop-formatted message"
+                               message: 'horrible desktop-formatted message'
                        }
-               } ), "call fail with type and message" );
-               assert.ok( !doneSpy.called, "don't call done" );
+               } ), 'call fail with type and message' );
+               assert.ok( !doneSpy.called, 'don\'t call done' );
        } );
 
-       QUnit.test( '#save, AbuseFilter other', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
),
-                       doneSpy = this.sandbox.spy(), failSpy = 
this.sandbox.spy();
+       QUnit.test( '#save, AbuseFilter other', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                               title: 'test',
+                               sectionId: 1
+                       } ),
+                       doneSpy = this.sandbox.spy(),
+                       failSpy = this.sandbox.spy();
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {
                        edit: {
-                               code: "abusefilter-something",
-                               info: "Scary filter",
-                               warning: "horrible desktop-formatted message",
-                               result: "Failure"
+                               code: 'abusefilter-something',
+                               info: 'Scary filter',
+                               warning: 'horrible desktop-formatted message',
+                               result: 'Failure'
                        }
                } ) );
 
@@ -304,20 +392,24 @@
                        type: 'abusefilter',
                        details: {
                                type: 'other',
-                               message: "horrible desktop-formatted message"
+                               message: 'horrible desktop-formatted message'
                        }
-               } ), "call fail with type and message" );
-               assert.ok( !doneSpy.called, "don't call done" );
+               } ), 'call fail with type and message' );
+               assert.ok( !doneSpy.called, 'don\'t call done' );
        } );
 
-       QUnit.test( '#save, extension errors', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
),
-                       doneSpy = this.sandbox.spy(), failSpy = 
this.sandbox.spy();
+       QUnit.test( '#save, extension errors', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                               title: 'test',
+                               sectionId: 1
+                       } ),
+                       doneSpy = this.sandbox.spy(),
+                       failSpy = this.sandbox.spy();
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {
                        edit: {
-                               code: "testerror",
-                               result: "Failure"
+                               code: 'testerror',
+                               result: 'Failure'
                        }
                } ) );
 
@@ -326,13 +418,20 @@
 
                editorApi.save().done( doneSpy ).fail( failSpy );
 
-               assert.ok( failSpy.calledWith( { type: 'error', details: 
'testerror' } ), "call fail with code" );
-               assert.ok( !doneSpy.called, "don't call done" );
+               assert.ok( failSpy.calledWith( {
+                       type: 'error',
+                       details: 'testerror'
+               } ), 'call fail with code' );
+               assert.ok( !doneSpy.called, 'don\'t call done' );
        } );
 
-       QUnit.test( '#save, unknown errors', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
),
-                       doneSpy = this.sandbox.spy(), failSpy = 
this.sandbox.spy();
+       QUnit.test( '#save, unknown errors', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                               title: 'test',
+                               sectionId: 1
+                       } ),
+                       doneSpy = this.sandbox.spy(),
+                       failSpy = this.sandbox.spy();
 
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {} ) );
 
@@ -341,77 +440,116 @@
 
                editorApi.save().done( doneSpy ).fail( failSpy );
 
-               assert.ok( failSpy.calledWith( { type: 'error', details: 
'unknown' } ), "call fail with unknown" );
-               assert.ok( !doneSpy.called, "don't call done" );
+               assert.ok( failSpy.calledWith( {
+                       type: 'error',
+                       details: 'unknown'
+               } ), 'call fail with unknown' );
+               assert.ok( !doneSpy.called, 'don\'t call done' );
        } );
 
-       QUnit.test( '#save, without changes', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'test', sectionId: 1 } 
);
+       QUnit.test( '#save, without changes', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'test',
+                       sectionId: 1
+               } );
 
                assert.throws(
-                       function() {
+                       function () {
                                editorApi.save();
                        },
                        /no changes/i,
                        'throw an error'
                );
-               assert.ok( !editorApi.getToken.called, "don't get the token" );
+               assert.ok( !editorApi.getToken.called, 'don\'t get the token' );
        } );
 
-       QUnit.test( '#getPreview', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'Test', sectionId: 1 } 
), doneSpy = this.sandbox.spy();
+       QUnit.test( '#getPreview', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'Test',
+                       sectionId: 1
+               } ), doneSpy = this.sandbox.spy();
                this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {
-                       "parse": {
-                               "title": "test",
-                               "text": { "*": "<h1>Heading 1</h1><h2>Heading 
2</h2><p>test content</p>" }
-                       }
-               } ) );
-
-               editorApi.getPreview( { text: "test content" } ).done( doneSpy 
);
-
-               assert.ok( editorApi.post.calledWithMatch( { text: "test 
content" } ) );
-               assert.ok( doneSpy.calledWith( '<h1>Heading 1</h1><h2>Heading 
2</h2><p>test content</p>' ) );
-       } );
-
-       QUnit.test( '#getPreview, check without sectionLine', 1, function( 
assert ) {
-               var editorApi = new EditorApi( { title: 'Test', sectionId: 1 } 
);
-               this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {
-                       "parse": {
-                               "title": "test",
-                               "text": { "*": "test content" },
-                               "sections": {}
-                       }
-               } ) );
-
-               editorApi.getPreview( { text: "test content" } ).done( 
function( text, sectionLine ) {
-                       assert.strictEqual( sectionLine, '', 'Ok, no section 
line returned' );
-               } );
-       } );
-
-       QUnit.test( '#getPreview, check with sectionLine', 1, function( assert 
) {
-               var editorApi = new EditorApi( { title: 'Test', sectionId: 1 } 
);
-               this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {
-                       "parse": {
-                               "title": "test",
-                               "text": { "*": "test content" },
-                               "sections": {
-                                       0: { "line": "Testsection" },
-                                       1: { "line": "Testsection2" }
+                       parse: {
+                               title: 'test',
+                               text: {
+                                       '*': '<h1>Heading 1</h1><h2>Heading 
2</h2><p>test content</p>'
                                }
                        }
                } ) );
 
-               editorApi.getPreview( { text: "test content" } ).done( 
function( text, sectionLine ) {
+               editorApi.getPreview( {
+                       text: 'test content'
+               } ).done( doneSpy );
+
+               assert.ok( editorApi.post.calledWithMatch( {
+                       text: 'test content'
+               } ) );
+               assert.ok( doneSpy.calledWith( '<h1>Heading 1</h1><h2>Heading 
2</h2><p>test content</p>' ) );
+       } );
+
+       QUnit.test( '#getPreview, check without sectionLine', 1, function ( 
assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'Test',
+                       sectionId: 1
+               } );
+               this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {
+                       parse: {
+                               title: 'test',
+                               text: {
+                                       '*': 'test content'
+                               },
+                               sections: {}
+                       }
+               } ) );
+
+               editorApi.getPreview( {
+                       text: 'test content'
+               } ).done( function ( text, sectionLine ) {
+                       assert.strictEqual( sectionLine, '', 'Ok, no section 
line returned' );
+               } );
+       } );
+
+       QUnit.test( '#getPreview, check with sectionLine', 1, function ( assert 
) {
+               var editorApi = new EditorApi( {
+                       title: 'Test',
+                       sectionId: 1
+               } );
+               this.sandbox.stub( editorApi, 'post' ).returns( 
$.Deferred().resolve( {
+                       parse: {
+                               title: 'test',
+                               text: {
+                                       '*': 'test content'
+                               },
+                               sections: {
+                                       0: {
+                                               line: 'Testsection'
+                                       },
+                                       1: {
+                                               line: 'Testsection2'
+                                       }
+                               }
+                       }
+               } ) );
+
+               editorApi.getPreview( {
+                       text: 'test content'
+               } ).done( function ( text, sectionLine ) {
                        assert.strictEqual( sectionLine, 'Testsection', 'Ok, 
section line returned' );
                } );
        } );
 
-       QUnit.test( '#save, when token has expired', 2, function( assert ) {
-               var editorApi = new EditorApi( { title: 'MediaWiki:Test.css' } 
);
+       QUnit.test( '#save, when token has expired', 2, function ( assert ) {
+               var editorApi = new EditorApi( {
+                       title: 'MediaWiki:Test.css'
+               } );
 
                this.sandbox.stub( editorApi, 'post' )
-                       .onFirstCall().returns( $.Deferred().reject( "badtoken" 
) )
-                       .onSecondCall().returns( $.Deferred().resolve( 
{"edit":{"result":"Success"}} ) );
+                       .onFirstCall().returns( $.Deferred().reject( 'badtoken' 
) )
+                       .onSecondCall().returns( $.Deferred().resolve( {
+                               edit: {
+                                       result: 'Success'
+                               }
+                       } ) );
 
                editorApi.getToken
                        .onFirstCall().returns( $.Deferred().resolve( 
'cachedbadtoken' ) )
diff --git a/tests/qunit/modules/editor/test_EditorOverlay.js 
b/tests/qunit/modules/editor/test_EditorOverlay.js
index 33b1489..0621470 100644
--- a/tests/qunit/modules/editor/test_EditorOverlay.js
+++ b/tests/qunit/modules/editor/test_EditorOverlay.js
@@ -1,3 +1,4 @@
+//jscs:disable jsDoc
 ( function ( M, $ ) {
 
        var EditorApi = M.require( 'modules/editor/EditorApi' ),
@@ -5,7 +6,7 @@
                apiSpy;
 
        QUnit.module( 'MobileFrontend modules/editor/EditorOverlay', {
-               setup: function() {
+               setup: function () {
                        apiSpy = this.sandbox.spy( EditorApi.prototype, 
'initialize' );
 
                        // prevent event logging requests
@@ -17,22 +18,33 @@
                }
        } );
 
-       QUnit.test( '#initialize, with given page and section', 3, function( 
assert ) {
-               var editorOverlay = new EditorOverlay( { title: 'test', 
sectionId: 0 } );
+       QUnit.test( '#initialize, with given page and section', 3, function ( 
assert ) {
+               var editorOverlay = new EditorOverlay( {
+                       title: 'test',
+                       sectionId: 0
+               } );
 
                assert.ok( apiSpy.calledOnce, 'initialize EditorApi once' );
-               assert.ok( apiSpy.calledWithMatch( { title: 'test', isNewPage: 
undefined, oldId: undefined, sectionId: 0} ), 'initialize EditorApi with 
correct pageTitle' );
+               assert.ok( apiSpy.calledWithMatch( {
+                       title: 'test',
+                       isNewPage: undefined,
+                       oldId: undefined,
+                       sectionId: 0
+               } ), 'initialize EditorApi with correct pageTitle' );
                assert.strictEqual( editorOverlay.$content.val(), 'section 0', 
'load correct section' );
        } );
 
-       QUnit.test( '#preview', 1, function( assert ) {
-               var editorOverlay = new EditorOverlay( { title: 'test', 
sectionId: 0 } );
+       QUnit.test( '#preview', 1, function ( assert ) {
+               var editorOverlay = new EditorOverlay( {
+                       title: 'test',
+                       sectionId: 0
+               } );
 
                editorOverlay.onStageChanges();
                assert.strictEqual( editorOverlay.$preview.text(), 
'\npreviewtest\n', 'preview loaded correctly' );
        } );
 
-       QUnit.test( '#without-preview', 1, function( assert ) {
+       QUnit.test( '#without-preview', 1, function ( assert ) {
                var editorOverlay;
 
                this.sandbox.stub( mw.config, 'get' ).withArgs( 
'wgMFEditorOptions' ).returns( {
@@ -40,19 +52,32 @@
                        anonymousEditing: true
                } );
 
-               editorOverlay = new EditorOverlay( { title: 'test', sectionId: 
0 } );
+               editorOverlay = new EditorOverlay( {
+                       title: 'test',
+                       sectionId: 0
+               } );
                assert.strictEqual( editorOverlay.$( '.continue' ).text(), 
'Save', 'no preview loaded' );
        } );
 
-       QUnit.test( '#initialize, without a section', 2, function( assert ) {
-               new EditorOverlay( { title: 'test.css' } );
+       QUnit.test( '#initialize, without a section', 2, function ( assert ) {
+               new EditorOverlay( {
+                       title: 'test.css'
+               } );
 
                assert.ok( apiSpy.calledOnce, 'initialize EditorApi once' );
-               assert.ok( apiSpy.calledWithMatch( { title: 'test.css', 
isNewPage: undefined, oldId: undefined, sectionId: undefined } ), 'initialize 
EditorApi without a section' );
+               assert.ok( apiSpy.calledWithMatch( {
+                       title: 'test.css',
+                       isNewPage: undefined,
+                       oldId: undefined,
+                       sectionId: undefined
+               } ), 'initialize EditorApi without a section' );
        } );
 
-       QUnit.test( '#initialize, as anonymous', 1, function( assert ) {
-               var editorOverlay = new EditorOverlay( { title: 'Main_page', 
isAnon: true } );
+       QUnit.test( '#initialize, as anonymous', 1, function ( assert ) {
+               var editorOverlay = new EditorOverlay( {
+                       title: 'Main_page',
+                       isAnon: true
+               } );
 
                assert.ok( editorOverlay.$anonWarning.length > 0, 
'Editorwarning (IP will be saved) visible.' );
        } );

-- 
To view, visit https://gerrit.wikimedia.org/r/183538
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd4ec82ca51000f2695dc22984758d5b25f5e6ec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <bmansu...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to