From f05c96324c54716ddbe5ceb4ea1c3361e11c0c6e Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Wed, 21 Aug 2013 17:34:02 +0200 Subject: [PATCH] split test file into 2 files, make it easier to read --- test/spec/mkws-index-jsdom.spec.js | 57 +++++++++++++++++++++++++++++++++++ test/spec/mkws-index-simple.spec.js | 50 ------------------------------ 2 files changed, 57 insertions(+), 50 deletions(-) create mode 100644 test/spec/mkws-index-jsdom.spec.js diff --git a/test/spec/mkws-index-jsdom.spec.js b/test/spec/mkws-index-jsdom.spec.js new file mode 100644 index 0000000..fa31fea --- /dev/null +++ b/test/spec/mkws-index-jsdom.spec.js @@ -0,0 +1,57 @@ +/* Copyright (c) 2013 IndexData ApS. http://indexdata.com + * + * jQuery test with DOM/windows object + * + */ + + +var fs = require("fs"); +var utils = require("./mkws_utils.js"); + +/* + * 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); + }); + }); +} + +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); diff --git a/test/spec/mkws-index-simple.spec.js b/test/spec/mkws-index-simple.spec.js index eeda1a8..7fd542f 100644 --- a/test/spec/mkws-index-simple.spec.js +++ b/test/spec/mkws-index-simple.spec.js @@ -45,58 +45,8 @@ function html_check (file, tags_array, ignore_doctype) { }); } - -/* - * 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); -- 1.7.10.4