move the SP related test to a new directory ./spec-sp
[mkws-moved-to-github.git] / test / spec-sp / mkws_utils.js
diff --git a/test/spec-sp/mkws_utils.js b/test/spec-sp/mkws_utils.js
new file mode 100644 (file)
index 0000000..3256f70
--- /dev/null
@@ -0,0 +1,43 @@
+/* Copyright (c) 2013 IndexData ApS. http://indexdata.com
+ *
+ * helper functions for other test *.spec.js files
+ *
+ */
+
+/*
+ * combine arrays, return a flat list
+ * [["a","b"], ["c"], "d"] => ["a", "b", "c", "d"]
+ *
+ */
+var flat_list = function (list) {
+        var data = [];
+
+        for (var i = 0; i < list.length; i++) {
+            if (typeof list[i] == 'object') {
+                for (var j = 0; j < list[i].length; j++) {
+                    data.push(list[i][j]);
+                }
+
+            } else {
+                data.push(list[i]);
+            }
+        }
+
+        return data;
+    };
+
+/*
+ * list of div id to check
+ *
+ */
+var tags = {
+    required: ["mkwsSearch", "mkwsResults"],
+    optional: ["mkwsLang", "mkwsTargets"],
+    optional2: ["mkwsMOTD", "mkwsStat", "footer"]
+};
+
+// node.js exports
+module.exports = {
+    flat_list: flat_list,
+    tags: tags
+};