jenkins-bot has submitted this change and it was merged.
Change subject: qunit: Use sinon sandbox for mediawiki.api.parse.test
......................................................................
qunit: Use sinon sandbox for mediawiki.api.parse.test
This is the last of the mediawiki.api tests that was still making
real requests.
This test had become a parser test for no reason. It is supposed
to test the logic in mediawiki.api.parse which is only:
* making the correct request url
* extract data from response
Change-Id: I9b6eeabe1baa1de7d77623902ef71ba031eb40ac
---
M tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js
M tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
2 files changed, 25 insertions(+), 24 deletions(-)
Approvals:
Bartosz Dziewoński: Looks good to me, approved
jenkins-bot: Verified
diff --git
a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js
b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js
index 2bed9b9..70bcaf9 100644
--- a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js
+++ b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js
@@ -1,28 +1,29 @@
-( function ( mw, $ ) {
- QUnit.module( 'mediawiki.api.parse', QUnit.newMwEnvironment() );
+( function ( mw ) {
+ QUnit.module( 'mediawiki.api.parse', QUnit.newMwEnvironment( {
+ setup: function () {
+ this.clock = this.sandbox.useFakeTimers();
+ this.server = this.sandbox.useFakeServer();
+ },
+ teardown: function () {
+ this.clock.tick( 1 );
+ }
+ } ) );
- QUnit.asyncTest( 'Hello world', function ( assert ) {
- var api;
- QUnit.expect( 6 );
+ QUnit.test( 'Hello world', function ( assert ) {
+ QUnit.expect( 1 );
- api = new mw.Api();
+ var api = new mw.Api();
- api.parse( '\'\'\'Hello world\'\'\'' )
- .done( function ( html ) {
- // Parse into a document fragment instead of
comparing HTML, due to
- // presence of Tidy influencing whitespace.
- // Html also contains "NewPP report" comment.
- var $res = $( '<div>' ).html( html ).children(),
- res = $res.get( 0 );
- assert.equal( $res.length, 1, 'Response
contains 1 element' );
- assert.equal( res.nodeName.toLowerCase(), 'p',
'Response is a paragraph' );
- assert.equal( $res.children().length, 1,
'Response has 1 child element' );
- assert.equal( $res.children().get( 0
).nodeName.toLowerCase(), 'b', 'Child element is a bold tag' );
- // Trim since Tidy may or may not mess with the
spacing here
- assert.equal( $.trim( $res.text() ), 'Hello
world', 'Response contains given text' );
- assert.equal( $res.find( 'b' ).text(), 'Hello
world', 'Bold tag wraps the entire, same, text' );
+ api.parse( '\'\'\'Hello world\'\'\'' ).done( function ( html ) {
+ assert.equal( html, '<p><b>Hello world</b></p>' );
+ } );
- QUnit.start();
- } );
+ this.server.respondWith(
/action=parse.*&text='''Hello\+world'''/, function ( request ) {
+ request.respond( 200, { 'Content-Type':
'application/json' },
+ '{ "parse": { "text": { "*": "<p><b>Hello
world</b></p>" } } }'
+ );
+ } );
+
+ this.server.respond();
} );
-}( mediaWiki, jQuery ) );
+}( mediaWiki ) );
diff --git a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
index c903193..2ad7622 100644
--- a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
+++ b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js
@@ -7,7 +7,7 @@
teardown: function () {
this.clock.tick( 1 );
}
- }) );
+ } ) );
QUnit.test( 'Basic functionality', function ( assert ) {
QUnit.expect( 2 );
--
To view, visit https://gerrit.wikimedia.org/r/117005
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9b6eeabe1baa1de7d77623902ef71ba031eb40ac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Helder.wiki <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits