1 /* Copyright (c) 2013 IndexData ApS. http://indexdata.com
3 * jQuery test with DOM/windows object
7 var file = '../examples/htdocs/index-full.html'
9 var jsdom = require('jsdom').jsdom;
10 var myWindow = jsdom().createWindow();
11 var $ = jQuery = require('jquery').create(myWindow);
13 var fs = require("fs");
14 var index_full = fs.readFileSync(file, "utf-8");
16 var mkws_tags_required = ["mkwsSearch", "mkwsResults"];
17 var mkws_tags_optional = ["mkwsSwitch", "mkwsLang", "mkwsTargets"];
18 var mkws_tags_optional2 = ["mkwsMOTD", "mkwsStat", "footer"];
21 * combine arrays, return a flat list
22 * [["a","b"], ["c"], "d"] => ["a", "b", "c", "d"]
25 function flat_list (list) {
28 for(var i = 0; i < list.length; i++) {
29 if (typeof list[i] == 'object') {
30 for(var j = 0; j < list[i].length; j++) {
31 data.push(list[i][j]);
43 describe("index-full.html test", function() {
44 it("html test", function() {
45 expect(index_full).toBeDefined();
47 expect(index_full).toMatch(/<html.*?>/); // forgotten doctype?
48 expect(index_full).toMatch(/<head.*?>/);
49 expect(index_full).toMatch(/<body.*?>/);
50 expect(index_full).toMatch(/<\/html.*?>/);
51 expect(index_full).toMatch(/<\/head.*?>/);
52 expect(index_full).toMatch(/<\/body.*?>/);
54 expect(index_full).toMatch(/<meta .*?charset=utf-8/i);
55 expect(index_full).toMatch(/<title>.+<\/title>/i);
56 expect(index_full).toMatch(/<link .*?type="text\/css" href=".*?\/mkwsStyle.css"/);
58 var tags = flat_list([mkws_tags_required, mkws_tags_optional, mkws_tags_optional2]);
60 for(var i = 0, data = ""; i < tags.length; i++) {
61 data = '<div id="' + tags[i] + '">';
63 expect(index_full).toMatch(data);