Bartosz Dziewoński has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/352538 )
Change subject: windows: Add tests for OO.ui.alert/confirm/prompt ...................................................................... windows: Add tests for OO.ui.alert/confirm/prompt Change I9dbc9852434caba15 fixed the openWindow() promise to work with both jQuery 1 and jQuery 3. Now that the alert/confirm/prompt methods work again, add tests for them. Bug: T163510 Change-Id: I6605ca52b8207c7707a790b5a5bf7a383387df4c --- M Gruntfile.js M tests/index.php A tests/windows.test.js 3 files changed, 70 insertions(+), 0 deletions(-) Approvals: Aaron Schulz: Looks good to me, but someone else must approve Bartosz Dziewoński: Looks good to me, approved jenkins-bot: Verified diff --git a/Gruntfile.js b/Gruntfile.js index ac995a3..af06104 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -422,6 +422,7 @@ 'tests/core.test.js', 'tests/Element.test.js', 'tests/Process.test.js', + 'tests/windows.test.js', 'tests/mixins/*.test.js', 'tests/widgets/*.test.js', 'tests/JSPHP.test.js' diff --git a/tests/index.php b/tests/index.php index 4c08027..8c0d3ec 100644 --- a/tests/index.php +++ b/tests/index.php @@ -37,6 +37,7 @@ <script src="./core.test.js"></script> <script src="./Element.test.js"></script> <script src="./Process.test.js"></script> + <script src="./windows.test.js"></script> <script src="./mixins/FlaggedElement.test.js"></script> <script src="./widgets/TagMultiselectWidget.test.js"></script> <script src="./widgets/MenuTagMultiselectWidget.test.js"></script> diff --git a/tests/windows.test.js b/tests/windows.test.js new file mode 100644 index 0000000..dc1ff61 --- /dev/null +++ b/tests/windows.test.js @@ -0,0 +1,68 @@ +QUnit.module( 'windows' ); + +QUnit.test( 'alert()', function ( assert ) { + OO.ui.getWindowManager().once( 'opening', function ( win, opened ) { + opened.progress( function ( notif ) { + if ( notif.state === 'ready' ) { + win.executeAction( 'accept' ); + } + } ); + } ); + return OO.ui.alert( 'Text' ).then( function ( data ) { + assert.strictEqual( data, undefined ); + } ); +} ); + +QUnit.test( 'confirm() - accept', function ( assert ) { + OO.ui.getWindowManager().once( 'opening', function ( win, opened ) { + opened.progress( function ( notif ) { + if ( notif.state === 'ready' ) { + win.executeAction( 'accept' ); + } + } ); + } ); + return OO.ui.confirm( 'Text' ).then( function ( result ) { + assert.strictEqual( result, true, 'Accepted' ); + } ); +} ); + +QUnit.test( 'confirm() - reject', function ( assert ) { + OO.ui.getWindowManager().once( 'opening', function ( win, opened ) { + opened.progress( function ( notif ) { + if ( notif.state === 'ready' ) { + win.executeAction( 'reject' ); + } + } ); + } ); + return OO.ui.confirm( 'Text' ).then( function ( result ) { + assert.strictEqual( result, false, 'Rejected' ); + } ); +} ); + +QUnit.test( 'prompt() - accept', function ( assert ) { + OO.ui.getWindowManager().once( 'opening', function ( win, opened ) { + opened.progress( function ( notif ) { + if ( notif.state === 'ready' ) { + win.$body.find( 'input[type="text"]' ).val( 'Hello' ); + win.executeAction( 'accept' ); + } + } ); + } ); + return OO.ui.prompt( 'Text' ).then( function ( result ) { + assert.strictEqual( result, 'Hello', 'Accepted - text value' ); + } ); +} ); + +QUnit.test( 'prompt() - reject', function ( assert ) { + OO.ui.getWindowManager().once( 'opening', function ( win, opened ) { + opened.progress( function ( notif ) { + if ( notif.state === 'ready' ) { + win.$body.find( 'input[type="text"]' ).val( 'Hello' ); + win.executeAction( 'reject' ); + } + } ); + } ); + return OO.ui.prompt( 'Text' ).then( function ( result ) { + assert.strictEqual( result, null, 'Rejected' ); + } ); +} ); -- To view, visit https://gerrit.wikimedia.org/r/352538 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6605ca52b8207c7707a790b5a5bf7a383387df4c Gerrit-PatchSet: 7 Gerrit-Project: oojs/ui Gerrit-Branch: master Gerrit-Owner: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Divec <da...@troi.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits