Henning Snater has uploaded a new change for review.
https://gerrit.wikimedia.org/r/65809
Change subject: [coordinate.js] Basic parser QUnit tests
......................................................................
[coordinate.js] Basic parser QUnit tests
Change-Id: Ifdf3e74ae45a9933b815950a95b790c9b35076d0
---
M DataValues/DataValues.tests.qunit.php
A DataValues/resources/coordinate.js/tests/coordinate.parser.tests.js
2 files changed, 60 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues
refs/changes/09/65809/1
diff --git a/DataValues/DataValues.tests.qunit.php
b/DataValues/DataValues.tests.qunit.php
index 703002e..104de3a 100644
--- a/DataValues/DataValues.tests.qunit.php
+++ b/DataValues/DataValues.tests.qunit.php
@@ -83,6 +83,7 @@
'coordinate.js.tests' => array(
'scripts' => array(
'resources/coordinate.js/tests/coordinate.tests.js',
+
'resources/coordinate.js/tests/coordinate.parser.tests.js',
),
'dependencies' => array(
'coordinate.js',
diff --git
a/DataValues/resources/coordinate.js/tests/coordinate.parser.tests.js
b/DataValues/resources/coordinate.js/tests/coordinate.parser.tests.js
new file mode 100644
index 0000000..56c85ef
--- /dev/null
+++ b/DataValues/resources/coordinate.js/tests/coordinate.parser.tests.js
@@ -0,0 +1,59 @@
+/**
+ * @since 0.1
+ * @file
+ * @ingroup coordinate.js
+ *
+ * @licence GNU GPL v2+
+ * @author H. Snater < [email protected] >
+ */
+( function( QUnit, $, coordinate ) {
+ 'use strict';
+
+ var valid = {
+ '0': [0, 0, 1],
+ '-3 +2': [-3, 2, 1],
+ '1.1 2': [1.1, 2, 0.1],
+ '120° 30.10°': [120.6, 0, 0.01], // FIXME: Should result in:
[120, 30.1, 0.01]
+ '5\'N, 10"E': [5, 10, 1], // FIXME: Should result in: [5,
0.16666666666666666, 0.016666666666666666]
+ '5\'S': [-5, 0, 1],
+ '1\' 1"': [1.0002777777777778, 0, 0.0002777777777777778],
+ '1\' 1.1"': [1.0003055555555556, 0, 0.00002777777777777778],
+ '190° 30" 1.123\'': [190.5, 1.123, 0.001],
+ '5\'N 0\' 10.5"W': [5, -0.002916666666666667,
0.00002777777777777778]
+ };
+
+ var invalid = [
+ //'', // FIXME: Do not parse an empty string successfully.
+ 'random string'
+ ];
+
+ QUnit.module( 'coordinate.parser.js' );
+
+ QUnit.test( 'Parsing valid values', function( assert ) {
+
+ $.each( valid, function( string, expected ) {
+
+ assert.deepEqual(
+ coordinate.parser.parse( string ),
+ expected,
+ 'Successfully parsed \'' + string + '\'.'
+ );
+
+ } );
+
+ } );
+
+ QUnit.test( 'Parsing invalid values', function( assert ) {
+
+ $.each( invalid, function( i, string ) {
+
+ assert.throws(
+ function() { coordinate.parser.parse( string );
},
+ 'Unable to parse \'' + string + '\'.'
+ );
+
+ } );
+
+ } );
+
+}( QUnit, jQuery, coordinate ) );
--
To view, visit https://gerrit.wikimedia.org/r/65809
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifdf3e74ae45a9933b815950a95b790c9b35076d0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits