function mkws_jasmine_init(delay) {
var currentWindowOnload = window.onload;
- window.onload = function() {
+ window.onload = function () {
if (currentWindowOnload) {
currentWindowOnload();
}
if (delay) {
- setTimeout(function() {
+ setTimeout(function () {
execJasmine()
}, delay);
} else {
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
- jasmineEnv.specFilter = function(spec) {
+ jasmineEnv.specFilter = function (spec) {
return htmlReporter.specFilter(spec);
};
};
/* EOF */
-
*
*/
-describe("jQuery suite simple", function() {
+describe("jQuery suite simple", function () {
var $ = require('jquery');
- it("jQuery append test", function() {
- $("body").append("<h1>test passes h1</h1>");
- expect( $("body").html() ).toMatch(/<h1>/);
- $("<p>this is a paragraph</p>").appendTo("h1");
- expect( $("body").html() ).toMatch(/this is a paragraph/);
+ it("jQuery append test", function () {
+ $("body").append("<h1>test passes h1</h1>");
+ expect($("body").html()).toMatch(/<h1>/);
+ $("<p>this is a paragraph</p>").appendTo("h1");
+ expect($("body").html()).toMatch(/this is a paragraph/);
});
- it("$ append test", function() {
+ it("$ append test", function () {
$("<h2>test passes h2</h2>").appendTo("body");
- expect( $("body").html() ).toMatch(/<h2>/);
+ expect($("body").html()).toMatch(/<h2>/);
$("<p>this is a second paragraph</p>").appendTo("h1");
- expect( $("body").html() ).toMatch(/this is a paragraph/);
+ expect($("body").html()).toMatch(/this is a paragraph/);
});
- it("more jquery tests", function() {
+ it("more jquery tests", function () {
// other tests
- expect( $("h2").html() ).toMatch(/test passes h2/);
- expect( $("h1").html() ).toMatch(/test passes h1/);
- expect( $("h1").html() ).not.toMatch(/^$/);
- expect( $("h1").html() ).not.toMatch(/foobar/);
+ expect($("h2").html()).toMatch(/test passes h2/);
+ expect($("h1").html()).toMatch(/test passes h1/);
+ expect($("h1").html()).not.toMatch(/^$/);
+ expect($("h1").html()).not.toMatch(/foobar/);
});
});
*
*/
-describe("jQuery suite", function() {
- var jsdom = require('jsdom').jsdom;
- var myWindow = jsdom().createWindow();
+describe("jQuery suite", function () {
+ var jsdom = require('jsdom').jsdom;
+ var myWindow = jsdom().createWindow();
- var $ = require('jquery');
- var jq = require('jquery').create();
- var jQuery = require('jquery').create(myWindow);
+ var $ = require('jquery');
+ var jq = require('jquery').create();
+ var jQuery = require('jquery').create(myWindow);
- it("jQuery append test", function() {
- jQuery("<h1>test passes h1</h1>").appendTo("body");
- expect( jQuery("body").html() ).toMatch(/<h1>/);
- });
+ it("jQuery append test", function () {
+ jQuery("<h1>test passes h1</h1>").appendTo("body");
+ expect(jQuery("body").html()).toMatch(/<h1>/);
+ });
- it("$ append test", function() {
- $("<h2>test passes h2</h2>").appendTo("body");
- expect( $("body").html() ).toMatch(/<h2>/);
- });
+ it("$ append test", function () {
+ $("<h2>test passes h2</h2>").appendTo("body");
+ expect($("body").html()).toMatch(/<h2>/);
+ });
- it("jq append test", function() {
- jq("<h2>test passes h2</h2>").appendTo("body");
- expect( jq("body").html() ).toMatch(/<h2>/);
- });
+ it("jq append test", function () {
+ jq("<h2>test passes h2</h2>").appendTo("body");
+ expect(jq("body").html()).toMatch(/<h2>/);
+ });
- it("window test", function() {
- expect(myWindow).toBeDefined();
- });
+ it("window test", function () {
+ expect(myWindow).toBeDefined();
+ });
});
*
*/
-describe("Check mkws_config object", function() {
- it("mkws_config exists", function() {
- expect(mkws_config).not.toBe(undefined);
- });
-
- it("mkws_config service proxy config", function() {
- expect(mkws_config.service_proxy_url).toBe(undefined);
- });
-
- it("mkws_config locale check German", function() {
- expect(mkws_locale_lang.de.Authors).toMatch(/^Autoren$/);
- expect(mkws_locale_lang.de.Location).toMatch(/^Ort$/);
- });
- it("mkws_config locale check Danish", function() {
- expect(mkws_locale_lang.da.Authors).toMatch(/^Forfattere$/);
- expect(mkws_locale_lang.da.Location).toMatch(/^Lokation$/);
- });
-
- it("mkws_config service proxy enabled", function() {
- expect(mkws_config.use_service_proxy).toBe(true);
- });
+describe("Check mkws_config object", function () {
+ it("mkws_config exists", function () {
+ expect(mkws_config).not.toBe(undefined);
+ });
+
+ it("mkws_config service proxy config", function () {
+ expect(mkws_config.service_proxy_url).toBe(undefined);
+ });
+
+ it("mkws_config locale check German", function () {
+ expect(mkws_locale_lang.de.Authors).toMatch(/^Autoren$/);
+ expect(mkws_locale_lang.de.Location).toMatch(/^Ort$/);
+ });
+ it("mkws_config locale check Danish", function () {
+ expect(mkws_locale_lang.da.Authors).toMatch(/^Forfattere$/);
+ expect(mkws_locale_lang.da.Location).toMatch(/^Lokation$/);
+ });
+
+ it("mkws_config service proxy enabled", function () {
+ expect(mkws_config.use_service_proxy).toBe(true);
+ });
});
-describe("Check pazpar2 config", function() {
- it("pazpar2path is a path or an full URL", function() {
- expect(pazpar2path).toMatch(/^(\/|http:\/\/)/)
- });
+describe("Check pazpar2 config", function () {
+ it("pazpar2path is a path or an full URL", function () {
+ expect(pazpar2path).toMatch(/^(\/|http:\/\/)/)
+ });
- it("usesessions false", function() {
- expect(usesessions).toBe(false);
- });
+ it("usesessions false", function () {
+ expect(usesessions).toBe(false);
+ });
- it("my_paz is defined", function() {
- expect(my_paz).not.toBe(undefined);
- });
+ it("my_paz is defined", function () {
+ expect(my_paz).not.toBe(undefined);
+ });
});
-describe("Check pazpar2 runtime", function() {
- it("pazpar2 was successfully initialize", function() {
- expect(mkws_config.error).toBe(undefined);
- });
+describe("Check pazpar2 runtime", function () {
+ it("pazpar2 was successfully initialize", function () {
+ expect(mkws_config.error).toBe(undefined);
+ });
});
*
*/
-function jsdom_check (file, tags_array, ignore_doctype) {
- var html = fs.readFileSync(file, "utf-8");
- var tags = utils.flat_list(tags_array);
+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();
+ 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 $ = require('jquery').create(window);
+ /* apply jquery to the window */
+ var $ = require('jquery').create(window);
- it("html jquery test", function() {
- expect(html).toBeDefined();
+ 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);
+ 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);
- }
- });
+ for (var i = 0; i < tags.length; i++) {
+ expect($("#" + tags[i]).length == 1).toEqual(true);
+ }
+ });
- it("html jquery fail test", function() {
- expect(html).toBeDefined();
+ 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);
+ 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]);
*
*/
-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(/<html.*?>/);
- expect(html).toMatch(/<\/html.*?>/);
- }
- expect(html).toMatch(/<head.*?>/);
- expect(html).toMatch(/<body.*?>/);
- expect(html).toMatch(/<\/head.*?>/);
- expect(html).toMatch(/<\/body.*?>/);
-
- expect(html).toMatch(/<meta .*?charset=utf-8/i);
- expect(html).toMatch(/<title>.+<\/title>/i);
- expect(html).toMatch(/<link .*?type="text\/css" href=".*?\/?mkwsStyle.css"/);
-
-
- for(var i = 0, data = ""; i < tags.length; i++) {
- data = '<div id="' + tags[i] + '">';
- // console.log(data)
- expect(html).toMatch(data);
- }
+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(/<html.*?>/);
+ expect(html).toMatch(/<\/html.*?>/);
+ }
+ expect(html).toMatch(/<head.*?>/);
+ expect(html).toMatch(/<body.*?>/);
+ expect(html).toMatch(/<\/head.*?>/);
+ expect(html).toMatch(/<\/body.*?>/);
+
+ expect(html).toMatch(/<meta .*?charset=utf-8/i);
+ expect(html).toMatch(/<title>.+<\/title>/i);
+ expect(html).toMatch(/<link .*?type="text\/css" href=".*?\/?mkwsStyle.css"/);
+
+
+ for (var i = 0, data = ""; i < tags.length; i++) {
+ data = '<div id="' + tags[i] + '">';
+ // console.log(data)
+ expect(html).toMatch(data);
+ }
+ });
});
- });
}
html_check('../examples/htdocs/index-full.html', [utils.tags.required, utils.tags.optional, utils.tags.optional2]);
*
*/
var flat_list = function (list) {
- var data = [];
+ var data = [];
- for(var i = 0; i < list.length; i++) {
- if (typeof list[i] == 'object') {
- for(var j = 0; j < list[i].length; j++) {
- data.push(list[i][j]);
- }
+ for (var i = 0; i < list.length; i++) {
+ if (typeof list[i] == 'object') {
+ for (var j = 0; j < list[i].length; j++) {
+ data.push(list[i][j]);
+ }
- } else {
- data.push(list[i]);
- }
- }
+ } else {
+ data.push(list[i]);
+ }
+ }
- return data;
-};
+ return data;
+ };
/*
* list of div id to check
*
*/
var tags = {
- required: ["mkwsSearch", "mkwsResults"],
- optional: ["mkwsSwitch", "mkwsLang", "mkwsTargets"],
- optional2: ["mkwsMOTD", "mkwsStat", "footer"]
+ required: ["mkwsSearch", "mkwsResults"],
+ optional: ["mkwsSwitch", "mkwsLang", "mkwsTargets"],
+ optional2: ["mkwsMOTD", "mkwsStat", "footer"]
};
// node.js exports
module.exports = {
- flat_list: flat_list,
- tags: tags
+ flat_list: flat_list,
+ tags: tags
};
*
*/
-describe('jasmine-node', function(){
+describe('jasmine-node', function () {
- it('should pass', function(){
- expect(1+2).toEqual(3);
- });
+ it('should pass', function () {
+ expect(1 + 2).toEqual(3);
+ });
- it('shows asynchronous test', function(){
- setTimeout(function(){
- expect('second').toEqual('second');
- asyncSpecDone();
- }, 1);
- expect('first').toEqual('first');
- asyncSpecWait();
- });
+ it('shows asynchronous test', function () {
+ setTimeout(function () {
+ expect('second').toEqual('second');
+ asyncSpecDone();
+ }, 1);
+ expect('first').toEqual('first');
+ asyncSpecWait();
+ });
- it('shows asynchronous test node-style', function(done){
- setTimeout(function(){
- expect('second').toEqual('second');
- // If you call done() with an argument, it will fail the spec
- // so you can use it as a handler for many async node calls
- done();
- }, 1);
- expect('first').toEqual('first');
- });
+ it('shows asynchronous test node-style', function (done) {
+ setTimeout(function () {
+ expect('second').toEqual('second');
+ // If you call done() with an argument, it will fail the spec
+ // so you can use it as a handler for many async node calls
+ done();
+ }, 1);
+ expect('first').toEqual('first');
+ });
});
* dummy test
*
*/
-describe("A suite", function() {
- it("contains spec with an expectation", function() {
- expect(true).toBe(true);
- });
+describe("A suite", function () {
+ it("contains spec with an expectation", function () {
+ expect(true).toBe(true);
+ });
});