From: Wolfram Schneider Date: Wed, 21 Aug 2013 15:31:16 +0000 (+0200) Subject: rename X-Git-Tag: 0.9.1~202^2~94 X-Git-Url: http://jsfdemo.indexdata.com/?a=commitdiff_plain;h=6766d6a434dc1d2fa4191c9673f517dd43a0f554;p=mkws-moved-to-github.git rename --- diff --git a/test/spec/mkws-index-full.spec.js b/test/spec/mkws-index-full.spec.js deleted file mode 100644 index ff90579..0000000 --- a/test/spec/mkws-index-full.spec.js +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (c) 2013 IndexData ApS. http://indexdata.com - * - * jQuery test with DOM/windows object - * - */ - - -var fs = require("fs"); -var utils = require("./mkws_utils.js"); - -/* - * simple test with string matching of the HTML page - * - */ - -function html_check (file, tags_array, ignore_doctype) { - var html = fs.readFileSync(file, "utf-8"); - var tags = utils.flat_list(tags_array); - - describe("index-full.html string test for " + file, function() { - it("html test", function() { - expect(html).toBeDefined(); - - // forgotten doctype declaration - if (!ignore_doctype) { - expect(html).toMatch(//); - expect(html).toMatch(/<\/html.*?>/); - } - expect(html).toMatch(//); - expect(html).toMatch(//); - expect(html).toMatch(/<\/head.*?>/); - expect(html).toMatch(/<\/body.*?>/); - - expect(html).toMatch(/.+<\/title>/i); - expect(html).toMatch(/'; - // console.log(data) - expect(html).toMatch(data); - } - }); - }); -} - - -/* - * parse HTML data to DOM, and run jQuery request on it - * - */ - -function jsdom_check (file, tags_array, ignore_doctype) { - var html = fs.readFileSync(file, "utf-8"); - var tags = utils.flat_list(tags_array); - - describe("index-full.html jsdom + jquery for " + file, function() { - var window = require('jsdom').jsdom(html, null, { - - FetchExternalResources: false, - ProcessExternalResources: false, - MutationEvents: false, - QuerySelector: false - }).createWindow(); - - /* apply jquery to the window */ - var $ = jQuery = require('jquery').create(window); - - - it("html jquery test", function() { - expect(html).toBeDefined(); - - expect($("body").length == 0).toEqual(false); - expect($("body").length == 1).toEqual(true); - expect($("head").length == 1).toEqual(true); - - for(var i = 0; i < tags.length; i++) { - expect($("#" + tags[i]).length == 1).toEqual(true); - } - }); - - it("html jquery fail test", function() { - expect(html).toBeDefined(); - - expect($("body_does_not_exists").length == 1).toEqual(false); - expect($("#body_does_not_exists").length == 1).toEqual(false); - }); - }); -} - -var mkws_tags_required = ["mkwsSearch", "mkwsResults"]; -var mkws_tags_optional = ["mkwsSwitch", "mkwsLang", "mkwsTargets"]; -var mkws_tags_optional2 = ["mkwsMOTD", "mkwsStat", "footer"]; - -html_check('../examples/htdocs/index-full.html', [mkws_tags_required, mkws_tags_optional, mkws_tags_optional2]); -html_check('../examples/htdocs/index-mobile.html', [mkws_tags_required, mkws_tags_optional]); -html_check('../examples/htdocs/index-popup.html', [], true); -html_check('../examples/htdocs/index-jquery.html', []); -html_check('../examples/htdocs/index-mike.html', [mkws_tags_required, mkws_tags_optional], true); - -jsdom_check('../examples/htdocs/index-full.html', [mkws_tags_required, mkws_tags_optional, mkws_tags_optional2]); -jsdom_check('../examples/htdocs/index-mobile.html', [mkws_tags_required, mkws_tags_optional]); -jsdom_check('../examples/htdocs/index-popup.html', [], true); -jsdom_check('../examples/htdocs/index-jquery.html', []); -jsdom_check('../examples/htdocs/index-mike.html', [mkws_tags_required, mkws_tags_optional], true); diff --git a/test/spec/mkws-index-simple.spec.js b/test/spec/mkws-index-simple.spec.js new file mode 100644 index 0000000..eeda1a8 --- /dev/null +++ b/test/spec/mkws-index-simple.spec.js @@ -0,0 +1,102 @@ +/* Copyright (c) 2013 IndexData ApS. http://indexdata.com + * + * jQuery test with DOM/windows object + * + */ + + +var fs = require("fs"); +var utils = require("./mkws_utils.js"); + +/* + * simple test with string matching of the HTML page + * + */ + +function html_check (file, tags_array, ignore_doctype) { + var html = fs.readFileSync(file, "utf-8"); + var tags = utils.flat_list(tags_array); + + describe("index-full.html string test for " + file, function() { + it("html test", function() { + expect(html).toBeDefined(); + + // forgotten doctype declaration + if (!ignore_doctype) { + expect(html).toMatch(//); + expect(html).toMatch(/<\/html.*?>/); + } + expect(html).toMatch(//); + expect(html).toMatch(//); + expect(html).toMatch(/<\/head.*?>/); + expect(html).toMatch(/<\/body.*?>/); + + expect(html).toMatch(/.+<\/title>/i); + expect(html).toMatch(/'; + // console.log(data) + expect(html).toMatch(data); + } + }); + }); +} + + +/* + * parse HTML data to DOM, and run jQuery request on it + * + */ + +function jsdom_check (file, tags_array, ignore_doctype) { + var html = fs.readFileSync(file, "utf-8"); + var tags = utils.flat_list(tags_array); + + describe("index-full.html jsdom + jquery for " + file, function() { + var window = require('jsdom').jsdom(html, null, { + + FetchExternalResources: false, + ProcessExternalResources: false, + MutationEvents: false, + QuerySelector: false + }).createWindow(); + + /* apply jquery to the window */ + var $ = jQuery = require('jquery').create(window); + + + it("html jquery test", function() { + expect(html).toBeDefined(); + + expect($("body").length == 0).toEqual(false); + expect($("body").length == 1).toEqual(true); + expect($("head").length == 1).toEqual(true); + + for(var i = 0; i < tags.length; i++) { + expect($("#" + tags[i]).length == 1).toEqual(true); + } + }); + + it("html jquery fail test", function() { + expect(html).toBeDefined(); + + expect($("body_does_not_exists").length == 1).toEqual(false); + expect($("#body_does_not_exists").length == 1).toEqual(false); + }); + }); +} + +html_check('../examples/htdocs/index-full.html', [utils.tags.required, utils.tags.optional, utils.tags.optional2]); +html_check('../examples/htdocs/index-mobile.html', [utils.tags.required, utils.tags.optional]); +html_check('../examples/htdocs/index-popup.html', [], true); +html_check('../examples/htdocs/index-jquery.html', []); +html_check('../examples/htdocs/index-mike.html', [utils.tags.required, utils.tags.optional], true); + +jsdom_check('../examples/htdocs/index-full.html', [utils.tags.required, utils.tags.optional, utils.tags.optional2]); +jsdom_check('../examples/htdocs/index-mobile.html', [utils.tags.required, utils.tags.optional]); +jsdom_check('../examples/htdocs/index-popup.html', [], true); +jsdom_check('../examples/htdocs/index-jquery.html', []); +jsdom_check('../examples/htdocs/index-mike.html', [utils.tags.required, utils.tags.optional], true);