Santhosh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/158347
Change subject: QUnit tests for isAbuse method of MTAbuseCard
..
QUnit tests for isAbuse method of MTAbuseCard
Change-Id: I963181ae43c2f6e73c7261d17daf36390de14b87
---
M ContentTranslation.hooks.php
A tests/qunit/ext.cx.tools.mtabuse.test.js
2 files changed, 63 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/47/158347/1
diff --git a/ContentTranslation.hooks.php b/ContentTranslation.hooks.php
index ea21786..1f9395c 100644
--- a/ContentTranslation.hooks.php
+++ b/ContentTranslation.hooks.php
@@ -100,8 +100,15 @@
*/
public static function addTestModules( array &$testModules,
ResourceLoader &$resourceLoader ) {
$testModules['qunit']['ext.cx.tools.tests'] = array(
- 'scripts' => array(
'tests/qunit/ext.cx.tools.template.test.js' ),
- 'dependencies' => array( 'ext.cx.model',
'ext.cx.tools.template' ),
+ 'scripts' => array(
+ 'tests/qunit/ext.cx.tools.template.test.js',
+ 'tests/qunit/ext.cx.tools.mtabuse.test.js'
+ ),
+ 'dependencies' => array(
+ 'ext.cx.model',
+ 'ext.cx.tools.template',
+ 'ext.cx.tools.mtabuse',
+ ),
'localBasePath' => __DIR__,
'remoteExtPath' => 'ContentTranslation',
);
diff --git a/tests/qunit/ext.cx.tools.mtabuse.test.js
b/tests/qunit/ext.cx.tools.mtabuse.test.js
new file mode 100644
index 000..1f8d5fc
--- /dev/null
+++ b/tests/qunit/ext.cx.tools.mtabuse.test.js
@@ -0,0 +1,54 @@
+/**
+ * QUnit tests for Content Translation.
+ *
+ * @file
+ * @ingroup Extensions
+ * @licence GPL-2.0+
+ */
+
+( function ( $, mw ) {
+ 'use strict';
+
+ QUnit.module( 'ext.cx.tools.mtabuse', QUnit.newMwEnvironment() );
+
+ QUnit.test( 'MT Abuse - isAbuse method tests', 5, function ( assert ) {
+ var progress, mtAbuseCard = new mw.cx.tools.mtabuse();
+ progress = {
+ any: 0,
+ human: 0,
+ mt: 0,
+ mtSectionsCount: 0
+ };
+ assert.assertFalse( mtAbuseCard.isAbuse( progress ), 'Beginning
of translation. Nothing done.' );
+ progress = {
+ any: 1.0,
+ human: 0.9,
+ mt: 0.1,
+ mtSectionsCount: 10
+ };
+ assert.assertFalse( mtAbuseCard.isAbuse( progress ),
'Translation with 90% human edits' );
+ progress = {
+ any: 0,
+ human: 0,
+ mt: 0.8,
+ mtSectionsCount: 2
+ };
+ assert.assertFalse( mtAbuseCard.isAbuse( progress ),
'Translation with 80% MT, but only 2 sections translated' );
+ progress = {
+ any: 0,
+ human: 0,
+ mt: 0.8,
+ mtSectionsCount: 6
+ };
+ assert.assertTrue( mtAbuseCard.isAbuse( progress ),
'Translation with 80% MT, 6 sections translated' );
+ progress = {
+ any: 0.76,
+ human: 0,
+ mt: 0.8,
+ mtSectionsCount: 5
+ };
+ assert.assertTrue( mtAbuseCard.isAbuse( progress ),
+ 'Translation with 80% MT, only 5 sections translated,
but total translation is 76%' );
+ } );
+
+}( jQuery, mediaWiki ) );
--
To view, visit https://gerrit.wikimedia.org/r/158347
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I963181ae43c2f6e73c7261d17daf36390de14b87
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits