Daniel Werner has submitted this change and it was merged.
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, 68 insertions(+), 0 deletions(-)
Approvals:
Daniel Werner: Verified; Looks good to me, approved
jenkins-bot: Verified
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..93ba076
--- /dev/null
+++ b/DataValues/resources/coordinate.js/tests/coordinate.parser.tests.js
@@ -0,0 +1,67 @@
+/**
+ * @since 0.1
+ * @file
+ * @ingroup coordinate.js
+ *
+ * @licence GNU GPL v2+
+ * @author H. Snater < [email protected] >
+ */
+( function( QUnit, $, coordinate ) {
+ 'use strict';
+
+ /**
+ * Valid coordinate strings:
+ * { <{string} input>: <{number[]} parse result> }
+ * @type {Object}
+ */
+ var valid = {
+ '0': [0, 0, 1],
+ '-3 +2': [-3, 2, 1],
+ '1.1 2': [1.1, 2, 0.1],
+ '90° N 30.10°': [90, 30.1, 0.01],
+ '0° 5\'N, 0° 0\' 10"E': [0.08333333333333333,
0.002777777777777778, 0.0002777777777777778],
+ '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]
+ };
+
+ /**
+ * Invalid coordinate strings.
+ * @type {string[]}
+ */
+ var invalid = [
+ 'random string'
+ ];
+
+ QUnit.module( 'coordinate.parser.js' );
+
+ QUnit.test( 'Parsing valid coordinate strings', function( assert ) {
+
+ $.each( valid, function( string, expected ) {
+
+ assert.deepEqual(
+ coordinate.parser.parse( string ),
+ expected,
+ 'Successfully parsed \'' + string + '\'.'
+ );
+
+ } );
+
+ } );
+
+ QUnit.test( 'Parsing invalid coordinate strings', 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: merged
Gerrit-Change-Id: Ifdf3e74ae45a9933b815950a95b790c9b35076d0
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits