6622f732750330e264a3e092217c1921afc25f67
[mkws-moved-to-github.git] / test / spec / mkws_utils.js
1 /* Copyright (c) 2013 IndexData ApS. http://indexdata.com
2  *
3  * helper functions for other test *.spec.js files
4  *
5  */
6
7 /*
8  * combine arrays, return a flat list
9  * [["a","b"], ["c"], "d"] => ["a", "b", "c", "d"]
10  *
11  */
12 var flat_list = function (list) {
13   var data = [];
14
15   for(var i = 0; i < list.length; i++) {
16       if (typeof list[i] == 'object') {
17         for(var j = 0; j < list[i].length; j++) {
18           data.push(list[i][j]);
19         }
20
21       } else {
22         data.push(list[i]);
23       }
24   }
25
26   return data;
27 };
28
29 /*
30  * list of div id to check
31  *
32  */
33 var tags = {
34         required: ["mkwsSearch", "mkwsResults"],
35         optional: ["mkwsSwitch", "mkwsLang", "mkwsTargets"],
36         optional2: ["mkwsMOTD", "mkwsStat", "footer"]
37 };
38
39 // node.js exports
40 module.exports = {
41         flat_list: flat_list,
42         tags: tags
43 };