[gnome-maps/wip/mlundblad/unit-tests: 2/2] WIP: Add unit tests for the utils module



commit 86a443ae809670168e6fb527ad8c541cad844903
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Apr 28 23:39:58 2020 +0200

    WIP: Add unit tests for the utils module

 tests/meson.build  |  2 +-
 tests/utilsTest.js | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index d3cf74e9..6276117f 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -4,7 +4,7 @@ script_conf.set('PACKAGE_VERSION', version)
 script_conf.set('libdir', libdir)
 script_conf.set('prefix', prefix)
 
-tests = []
+tests = ['utilsTest']
 
 foreach test : tests
   script_conf.set('name', test)
diff --git a/tests/utilsTest.js b/tests/utilsTest.js
new file mode 100644
index 00000000..16d832fd
--- /dev/null
+++ b/tests/utilsTest.js
@@ -0,0 +1,42 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2020 Marcus Lundblad
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+pkg.require({ 'Gdk': '3.0',
+              'Gtk': '3.0' });
+
+const JsUnit = imports.jsUnit;
+
+const Utils = imports.utils;
+
+const Geocode = imports.gi.GeocodeGlib;
+
+function main() {
+    osmTypeToStringTest();
+}
+
+function osmTypeToStringTest() {
+    JsUnit.assertEquals('OSM type node', 'node',
+                        Utils.osmTypeToString(Geocode.PlaceOsmType.NODE));
+    JsUnit.assertEquals('OSM type way', 'way',
+                        Utils.osmTypeToString(Geocode.PlaceOsmType.WAY));
+    JsUnit.assertEquals('OSM type node', 'relation',
+                        Utils.osmTypeToString(Geocode.PlaceOsmType.RELATION));
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]