7fd542f8c9871078c21823fb3084b9d7ed248ebe
[mkws-moved-to-github.git] / test / spec / mkws-index-simple.spec.js
1 /* Copyright (c) 2013 IndexData ApS. http://indexdata.com
2  *
3  * jQuery test with DOM/windows object
4  *
5  */
6
7
8 var fs = require("fs");
9 var utils = require("./mkws_utils.js");
10
11 /*
12  * simple test with string matching of the HTML page
13  *
14  */
15
16 function html_check (file, tags_array, ignore_doctype) {
17   var html = fs.readFileSync(file, "utf-8");
18   var tags = utils.flat_list(tags_array);
19
20   describe("index-full.html string test for " + file, function() {
21     it("html test", function() {
22       expect(html).toBeDefined();
23
24       // forgotten doctype declaration
25       if (!ignore_doctype) {
26         expect(html).toMatch(/<html.*?>/);
27         expect(html).toMatch(/<\/html.*?>/);
28       }
29       expect(html).toMatch(/<head.*?>/);
30       expect(html).toMatch(/<body.*?>/);
31       expect(html).toMatch(/<\/head.*?>/);
32       expect(html).toMatch(/<\/body.*?>/);
33
34       expect(html).toMatch(/<meta .*?charset=utf-8/i);
35       expect(html).toMatch(/<title>.+<\/title>/i);
36       expect(html).toMatch(/<link .*?type="text\/css" href=".*?\/?mkwsStyle.css"/);
37
38
39       for(var i = 0, data = ""; i < tags.length; i++) {
40         data = '<div id="' + tags[i] + '">';
41         // console.log(data)
42         expect(html).toMatch(data);
43       }
44     });
45   });
46 }
47
48 html_check('../examples/htdocs/index-full.html', [utils.tags.required, utils.tags.optional, utils.tags.optional2]);
49 html_check('../examples/htdocs/index-mobile.html', [utils.tags.required, utils.tags.optional]);
50 html_check('../examples/htdocs/index-popup.html', [], true);
51 html_check('../examples/htdocs/index-jquery.html', []);
52 html_check('../examples/htdocs/index-mike.html', [utils.tags.required, utils.tags.optional], true);