mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 09:50:27 +00:00
Upgrade to Jasmine 3 (#4226)
* process.exit() only exist in a node.js environment
* updateInterval has been removed from upstream
From upstream commit:
b6eb9a4d5e
* Update Jasmine to 3.4.0
* Reuse the evalInContext helper
* Fix expected parse result to match the actual result
* 'describe' cannot be nested inside 'it' blocks
Jasmine started to explicitly raise an error in these cases since:
https://github.com/jasmine/jasmine/pull/1411
* Be consistent about how to refer to library files
* Update link to Jasmine's official website
This commit is contained in:
parent
2deed528bc
commit
613f0b2559
@ -156,7 +156,7 @@ describe("HTML tag new parser tests", function() {
|
||||
null
|
||||
);
|
||||
expect(parser.parseTag("<mytag>",0)).toEqual(
|
||||
{ type : 'element', start : 0, attributes : [ ], tag : 'mytag', end : 7 }
|
||||
{ type : 'element', start : 0, attributes : { }, tag : 'mytag', end : 7 }
|
||||
);
|
||||
expect(parser.parseTag("<mytag attrib1>",0)).toEqual(
|
||||
{ type : 'element', start : 0, attributes : { attrib1 : { type : 'string', value : 'true', start : 6, name : 'attrib1', end : 14 } }, tag : 'mytag', end : 15 }
|
||||
|
@ -67,18 +67,16 @@ describe("Widget module", function() {
|
||||
var widgetNode = createWidgetNode(parseTreeNode,wiki);
|
||||
// Render the widget node to the DOM
|
||||
var wrapper = renderWidgetNode(widgetNode);
|
||||
describe("should render", function() {
|
||||
// Test the rendering
|
||||
expect(wrapper.innerHTML).toBe("A text node<div class=\"myClass\" title=\"myTitle\"> and the content of a DIV<div> and an inner DIV</div> and back in the outer DIV</div>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[1].children[0].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[1].children[1].sequenceNumber).toBe(4);
|
||||
expect(wrapper.children[1].children[1].children[0].sequenceNumber).toBe(5);
|
||||
expect(wrapper.children[1].children[2].sequenceNumber).toBe(6);
|
||||
});
|
||||
// Test the rendering
|
||||
expect(wrapper.innerHTML).toBe("A text node<div class=\"myClass\" title=\"myTitle\"> and the content of a DIV<div> and an inner DIV</div> and back in the outer DIV</div>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[1].children[0].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[1].children[1].sequenceNumber).toBe(4);
|
||||
expect(wrapper.children[1].children[1].children[0].sequenceNumber).toBe(5);
|
||||
expect(wrapper.children[1].children[2].sequenceNumber).toBe(6);
|
||||
});
|
||||
|
||||
it("should deal with transclude widgets and indirect attributes", function() {
|
||||
@ -111,38 +109,34 @@ describe("Widget module", function() {
|
||||
var widgetNode = createWidgetNode(parseTreeNode,wiki);
|
||||
// Render the widget node to the DOM
|
||||
var wrapper = renderWidgetNode(widgetNode);
|
||||
describe("should render", function() {
|
||||
// Test the rendering
|
||||
expect(wrapper.innerHTML).toBe("A text node<div class=\"myClass\" title=\"the quick brown fox\"> and the content of a DIV<div> and an inner DIV</div> and back in the outer DIVthe quick brown fox</div>the quick brown fox");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[1].children[0].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[1].children[1].sequenceNumber).toBe(4);
|
||||
expect(wrapper.children[1].children[1].children[0].sequenceNumber).toBe(5);
|
||||
expect(wrapper.children[1].children[2].sequenceNumber).toBe(6);
|
||||
expect(wrapper.children[1].children[3].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[2].sequenceNumber).toBe(8);
|
||||
});
|
||||
// Test the rendering
|
||||
expect(wrapper.innerHTML).toBe("A text node<div class=\"myClass\" title=\"the quick brown fox\"> and the content of a DIV<div> and an inner DIV</div> and back in the outer DIVthe quick brown fox</div>the quick brown fox");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[1].children[0].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[1].children[1].sequenceNumber).toBe(4);
|
||||
expect(wrapper.children[1].children[1].children[0].sequenceNumber).toBe(5);
|
||||
expect(wrapper.children[1].children[2].sequenceNumber).toBe(6);
|
||||
expect(wrapper.children[1].children[3].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[2].sequenceNumber).toBe(8);
|
||||
// Change the transcluded tiddler
|
||||
wiki.addTiddler({title: "TiddlerOne", text: "jumps over the lazy dog"});
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["TiddlerOne"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("A text node<div class=\"myClass\" title=\"jumps over the lazy dog\"> and the content of a DIV<div> and an inner DIV</div> and back in the outer DIVjumps over the lazy dog</div>jumps over the lazy dog");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[1].children[0].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[1].children[1].sequenceNumber).toBe(4);
|
||||
expect(wrapper.children[1].children[1].children[0].sequenceNumber).toBe(5);
|
||||
expect(wrapper.children[1].children[2].sequenceNumber).toBe(6);
|
||||
expect(wrapper.children[1].children[3].sequenceNumber).toBe(9);
|
||||
expect(wrapper.children[2].sequenceNumber).toBe(10);
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("A text node<div class=\"myClass\" title=\"jumps over the lazy dog\"> and the content of a DIV<div> and an inner DIV</div> and back in the outer DIVjumps over the lazy dog</div>jumps over the lazy dog");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[1].children[0].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[1].children[1].sequenceNumber).toBe(4);
|
||||
expect(wrapper.children[1].children[1].children[0].sequenceNumber).toBe(5);
|
||||
expect(wrapper.children[1].children[2].sequenceNumber).toBe(6);
|
||||
expect(wrapper.children[1].children[3].sequenceNumber).toBe(9);
|
||||
expect(wrapper.children[2].sequenceNumber).toBe(10);
|
||||
});
|
||||
|
||||
it("should detect recursion of the transclude macro", function() {
|
||||
@ -161,11 +155,8 @@ describe("Widget module", function() {
|
||||
var widgetNode = createWidgetNode(parseTreeNode,wiki);
|
||||
// Render the widget node to the DOM
|
||||
var wrapper = renderWidgetNode(widgetNode);
|
||||
describe("should detect the recursion", function() {
|
||||
// Test the rendering
|
||||
expect(wrapper.innerHTML).toBe("<span class=\"tc-error\">Recursive transclusion error in transclude widget</span>\n");
|
||||
});
|
||||
|
||||
// Test the rendering
|
||||
expect(wrapper.innerHTML).toBe("<span class=\"tc-error\">Recursive transclusion error in transclude widget</span>\n");
|
||||
});
|
||||
|
||||
it("should deal with SVG elements", function() {
|
||||
@ -218,14 +209,12 @@ describe("Widget module", function() {
|
||||
wiki.addTiddler({title: "TiddlerOne", text: "World-wide Jelly"});
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["TiddlerOne"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>World-wide Jelly</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(3);
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>World-wide Jelly</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(3);
|
||||
});
|
||||
|
||||
it("should deal with the set widget", function() {
|
||||
@ -248,16 +237,14 @@ describe("Widget module", function() {
|
||||
wiki.addTiddler({title: "TiddlerFour", text: "TiddlerOne"});
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["TiddlerFour"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>My Jolly Old World is Jolly</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(5);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(4);
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>My Jolly Old World is Jolly</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(5);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(4);
|
||||
});
|
||||
|
||||
it("should deal with attributes specified as macro invocations", function() {
|
||||
@ -306,49 +293,43 @@ describe("Widget module", function() {
|
||||
wiki.addTiddler({title: "TiddlerFive", text: "Jalapeno Peppers"});
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["TiddlerFive"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwo</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(6);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(4);
|
||||
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwo</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(6);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(4);
|
||||
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
|
||||
// Remove a tiddler
|
||||
wiki.deleteTiddler("TiddlerThree");
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["TiddlerThree"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerTwo</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(6);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(5);
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerTwo</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(6);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(5);
|
||||
// Add it back a tiddler
|
||||
wiki.addTiddler({title: "TiddlerThree", text: "Something"});
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["TiddlerThree"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwo</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(6);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwo</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(6);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
|
||||
});
|
||||
|
||||
it("should deal with the list widget followed by other widgets", function() {
|
||||
@ -373,65 +354,57 @@ describe("Widget module", function() {
|
||||
wiki.addTiddler({title: "TiddlerFive", text: "Jalapeno Peppers"});
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["TiddlerFive"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwoSomething</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(4);
|
||||
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwoSomething</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(4);
|
||||
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
|
||||
// Remove a tiddler
|
||||
wiki.deleteTiddler("TiddlerThree");
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["TiddlerThree"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerTwoSomething</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(5);
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerTwoSomething</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(5);
|
||||
// Add it back a tiddler
|
||||
wiki.addTiddler({title: "TiddlerThree", text: "Something"});
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["TiddlerThree"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwoSomething</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(8);
|
||||
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwoSomething</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(8);
|
||||
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
|
||||
// Add another a tiddler to the end of the list
|
||||
wiki.addTiddler({title: "YetAnotherTiddler", text: "Something"});
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["YetAnotherTiddler"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwoYetAnotherTiddlerSomething</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(8);
|
||||
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>TiddlerFiveTiddlerFourTiddlerOneTiddlerThreeTiddlerTwoYetAnotherTiddlerSomething</p>");
|
||||
// Test the sequence numbers in the DOM
|
||||
expect(wrapper.sequenceNumber).toBe(0);
|
||||
expect(wrapper.children[0].sequenceNumber).toBe(1);
|
||||
expect(wrapper.children[0].children[0].sequenceNumber).toBe(7);
|
||||
expect(wrapper.children[0].children[1].sequenceNumber).toBe(2);
|
||||
expect(wrapper.children[0].children[2].sequenceNumber).toBe(3);
|
||||
expect(wrapper.children[0].children[3].sequenceNumber).toBe(8);
|
||||
expect(wrapper.children[0].children[4].sequenceNumber).toBe(5);
|
||||
});
|
||||
|
||||
it("should deal with the list widget and external templates", function() {
|
||||
@ -488,10 +461,8 @@ describe("Widget module", function() {
|
||||
wiki.deleteTiddler("TiddlerFour");
|
||||
// Refresh
|
||||
refreshWidgetNode(widgetNode,wrapper,["TiddlerOne","TiddlerTwo","TiddlerThree","TiddlerFour"]);
|
||||
describe("should refresh", function() {
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>nothing</p>");
|
||||
});
|
||||
// Test the refreshing
|
||||
expect(wrapper.innerHTML).toBe("<p>nothing</p>");
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2008-2011 Pivotal Labs
|
||||
Copyright (c) 2008-2017 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
@ -0,0 +1,37 @@
|
||||
module.exports = require("./jasmine-core/jasmine.js");
|
||||
module.exports.boot = require('./jasmine-core/node_boot.js');
|
||||
|
||||
var path = require('path'),
|
||||
fs = require('fs');
|
||||
|
||||
var rootPath = path.join(__dirname, "jasmine-core"),
|
||||
bootFiles = ['boot.js'],
|
||||
nodeBootFiles = ['node_boot.js'],
|
||||
cssFiles = [],
|
||||
jsFiles = [],
|
||||
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, nodeBootFiles);
|
||||
|
||||
fs.readdirSync(rootPath).forEach(function(file) {
|
||||
if(fs.statSync(path.join(rootPath, file)).isFile()) {
|
||||
switch(path.extname(file)) {
|
||||
case '.css':
|
||||
cssFiles.push(file);
|
||||
break;
|
||||
case '.js':
|
||||
if (jsFilesToSkip.indexOf(file) < 0) {
|
||||
jsFiles.push(file);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports.files = {
|
||||
path: rootPath,
|
||||
bootDir: rootPath,
|
||||
bootFiles: bootFiles,
|
||||
nodeBootFiles: nodeBootFiles,
|
||||
cssFiles: cssFiles,
|
||||
jsFiles: ['jasmine.js'].concat(jsFiles),
|
||||
imagesDir: path.join(__dirname, '../images')
|
||||
};
|
@ -0,0 +1,158 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
/**
|
||||
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
|
||||
|
||||
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
|
||||
|
||||
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
|
||||
|
||||
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
/**
|
||||
* ## Require & Instantiate
|
||||
*
|
||||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
||||
*/
|
||||
window.jasmine = jasmineRequire.core(jasmineRequire);
|
||||
|
||||
/**
|
||||
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
|
||||
*/
|
||||
jasmineRequire.html(jasmine);
|
||||
|
||||
/**
|
||||
* Create the Jasmine environment. This is used to run all specs in a project.
|
||||
*/
|
||||
var env = jasmine.getEnv();
|
||||
|
||||
/**
|
||||
* ## The Global Interface
|
||||
*
|
||||
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
|
||||
*/
|
||||
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
|
||||
/**
|
||||
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
|
||||
*/
|
||||
extend(window, jasmineInterface);
|
||||
|
||||
/**
|
||||
* ## Runner Parameters
|
||||
*
|
||||
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
|
||||
*/
|
||||
|
||||
var queryString = new jasmine.QueryString({
|
||||
getWindowLocation: function() { return window.location; }
|
||||
});
|
||||
|
||||
var filterSpecs = !!queryString.getParam("spec");
|
||||
|
||||
var config = {
|
||||
failFast: queryString.getParam("failFast"),
|
||||
oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
|
||||
hideDisabled: queryString.getParam("hideDisabled")
|
||||
};
|
||||
|
||||
var random = queryString.getParam("random");
|
||||
|
||||
if (random !== undefined && random !== "") {
|
||||
config.random = random;
|
||||
}
|
||||
|
||||
var seed = queryString.getParam("seed");
|
||||
if (seed) {
|
||||
config.seed = seed;
|
||||
}
|
||||
|
||||
/**
|
||||
* ## Reporters
|
||||
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
||||
*/
|
||||
var htmlReporter = new jasmine.HtmlReporter({
|
||||
env: env,
|
||||
navigateWithNewParam: function(key, value) { return queryString.navigateWithNewParam(key, value); },
|
||||
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
|
||||
getContainer: function() { return document.body; },
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
||||
timer: new jasmine.Timer(),
|
||||
filterSpecs: filterSpecs
|
||||
});
|
||||
|
||||
/**
|
||||
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
|
||||
*/
|
||||
env.addReporter(jasmineInterface.jsApiReporter);
|
||||
env.addReporter(htmlReporter);
|
||||
|
||||
/**
|
||||
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
||||
*/
|
||||
var specFilter = new jasmine.HtmlSpecFilter({
|
||||
filterString: function() { return queryString.getParam("spec"); }
|
||||
});
|
||||
|
||||
config.specFilter = function(spec) {
|
||||
return specFilter.matches(spec.getFullName());
|
||||
};
|
||||
|
||||
env.configure(config);
|
||||
|
||||
/**
|
||||
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
|
||||
*/
|
||||
window.setTimeout = window.setTimeout;
|
||||
window.setInterval = window.setInterval;
|
||||
window.clearTimeout = window.clearTimeout;
|
||||
window.clearInterval = window.clearInterval;
|
||||
|
||||
/**
|
||||
* ## Execution
|
||||
*
|
||||
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
||||
*/
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
htmlReporter.initialize();
|
||||
env.execute();
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function for readability above.
|
||||
*/
|
||||
function extend(destination, source) {
|
||||
for (var property in source) destination[property] = source[property];
|
||||
return destination;
|
||||
}
|
||||
|
||||
}());
|
@ -0,0 +1,620 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
jasmineRequire.html = function(j$) {
|
||||
j$.ResultsNode = jasmineRequire.ResultsNode();
|
||||
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
||||
j$.QueryString = jasmineRequire.QueryString();
|
||||
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
||||
};
|
||||
|
||||
jasmineRequire.HtmlReporter = function(j$) {
|
||||
function ResultsStateBuilder() {
|
||||
this.topResults = new j$.ResultsNode({}, '', null);
|
||||
this.currentParent = this.topResults;
|
||||
this.specsExecuted = 0;
|
||||
this.failureCount = 0;
|
||||
this.pendingSpecCount = 0;
|
||||
}
|
||||
|
||||
ResultsStateBuilder.prototype.suiteStarted = function(result) {
|
||||
this.currentParent.addChild(result, 'suite');
|
||||
this.currentParent = this.currentParent.last();
|
||||
};
|
||||
|
||||
ResultsStateBuilder.prototype.suiteDone = function(result) {
|
||||
this.currentParent.updateResult(result);
|
||||
if (this.currentParent !== this.topResults) {
|
||||
this.currentParent = this.currentParent.parent;
|
||||
}
|
||||
|
||||
if (result.status === 'failed') {
|
||||
this.failureCount++;
|
||||
}
|
||||
};
|
||||
|
||||
ResultsStateBuilder.prototype.specStarted = function(result) {
|
||||
};
|
||||
|
||||
ResultsStateBuilder.prototype.specDone = function(result) {
|
||||
this.currentParent.addChild(result, 'spec');
|
||||
|
||||
if (result.status !== 'excluded') {
|
||||
this.specsExecuted++;
|
||||
}
|
||||
|
||||
if (result.status === 'failed') {
|
||||
this.failureCount++;
|
||||
}
|
||||
|
||||
if (result.status == 'pending') {
|
||||
this.pendingSpecCount++;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
function HtmlReporter(options) {
|
||||
var config = function() { return (options.env && options.env.configuration()) || {}; },
|
||||
getContainer = options.getContainer,
|
||||
createElement = options.createElement,
|
||||
createTextNode = options.createTextNode,
|
||||
navigateWithNewParam = options.navigateWithNewParam || function() {},
|
||||
addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
|
||||
filterSpecs = options.filterSpecs,
|
||||
timer = options.timer || j$.noopTimer,
|
||||
htmlReporterMain,
|
||||
symbols,
|
||||
deprecationWarnings = [];
|
||||
|
||||
this.initialize = function() {
|
||||
clearPrior();
|
||||
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
|
||||
createDom('div', {className: 'jasmine-banner'},
|
||||
createDom('a', {className: 'jasmine-title', href: 'http://jasmine.github.io/', target: '_blank'}),
|
||||
createDom('span', {className: 'jasmine-version'}, j$.version)
|
||||
),
|
||||
createDom('ul', {className: 'jasmine-symbol-summary'}),
|
||||
createDom('div', {className: 'jasmine-alert'}),
|
||||
createDom('div', {className: 'jasmine-results'},
|
||||
createDom('div', {className: 'jasmine-failures'})
|
||||
)
|
||||
);
|
||||
getContainer().appendChild(htmlReporterMain);
|
||||
};
|
||||
|
||||
var totalSpecsDefined;
|
||||
this.jasmineStarted = function(options) {
|
||||
totalSpecsDefined = options.totalSpecsDefined || 0;
|
||||
timer.start();
|
||||
};
|
||||
|
||||
var summary = createDom('div', {className: 'jasmine-summary'});
|
||||
|
||||
var stateBuilder = new ResultsStateBuilder();
|
||||
|
||||
this.suiteStarted = function(result) {
|
||||
stateBuilder.suiteStarted(result);
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {
|
||||
stateBuilder.suiteDone(result);
|
||||
|
||||
if (result.status === 'failed') {
|
||||
failures.push(failureDom(result));
|
||||
}
|
||||
addDeprecationWarnings(result);
|
||||
};
|
||||
|
||||
this.specStarted = function(result) {
|
||||
stateBuilder.specStarted(result);
|
||||
};
|
||||
|
||||
var failures = [];
|
||||
this.specDone = function(result) {
|
||||
stateBuilder.specDone(result);
|
||||
|
||||
if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') {
|
||||
console.error('Spec \'' + result.fullName + '\' has no expectations.');
|
||||
}
|
||||
|
||||
if (!symbols){
|
||||
symbols = find('.jasmine-symbol-summary');
|
||||
}
|
||||
|
||||
symbols.appendChild(createDom('li', {
|
||||
className: this.displaySpecInCorrectFormat(result),
|
||||
id: 'spec_' + result.id,
|
||||
title: result.fullName
|
||||
}
|
||||
));
|
||||
|
||||
if (result.status === 'failed') {
|
||||
failures.push(failureDom(result));
|
||||
}
|
||||
|
||||
addDeprecationWarnings(result);
|
||||
};
|
||||
|
||||
this.displaySpecInCorrectFormat = function(result) {
|
||||
return noExpectations(result) ? 'jasmine-empty' : this.resultStatus(result.status);
|
||||
};
|
||||
|
||||
this.resultStatus = function(status) {
|
||||
if(status === 'excluded') {
|
||||
return config().hideDisabled ? 'jasmine-excluded-no-display' : 'jasmine-excluded';
|
||||
}
|
||||
return 'jasmine-' + status;
|
||||
};
|
||||
|
||||
this.jasmineDone = function(doneResult) {
|
||||
var banner = find('.jasmine-banner');
|
||||
var alert = find('.jasmine-alert');
|
||||
var order = doneResult && doneResult.order;
|
||||
var i;
|
||||
alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
||||
|
||||
banner.appendChild(optionsMenu(config()));
|
||||
|
||||
if (stateBuilder.specsExecuted < totalSpecsDefined) {
|
||||
var skippedMessage = 'Ran ' + stateBuilder.specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
||||
var skippedLink = addToExistingQueryString('spec', '');
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'jasmine-bar jasmine-skipped'},
|
||||
createDom('a', {href: skippedLink, title: 'Run all specs'}, skippedMessage)
|
||||
)
|
||||
);
|
||||
}
|
||||
var statusBarMessage = '';
|
||||
var statusBarClassName = 'jasmine-overall-result jasmine-bar ';
|
||||
var globalFailures = (doneResult && doneResult.failedExpectations) || [];
|
||||
var failed = stateBuilder.failureCount + globalFailures.length > 0;
|
||||
|
||||
if (totalSpecsDefined > 0 || failed) {
|
||||
statusBarMessage += pluralize('spec', stateBuilder.specsExecuted) + ', ' + pluralize('failure', stateBuilder.failureCount);
|
||||
if (stateBuilder.pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', stateBuilder.pendingSpecCount); }
|
||||
}
|
||||
|
||||
if (doneResult.overallStatus === 'passed') {
|
||||
statusBarClassName += ' jasmine-passed ';
|
||||
} else if (doneResult.overallStatus === 'incomplete') {
|
||||
statusBarClassName += ' jasmine-incomplete ';
|
||||
statusBarMessage = 'Incomplete: ' + doneResult.incompleteReason + ', ' + statusBarMessage;
|
||||
} else {
|
||||
statusBarClassName += ' jasmine-failed ';
|
||||
}
|
||||
|
||||
var seedBar;
|
||||
if (order && order.random) {
|
||||
seedBar = createDom('span', {className: 'jasmine-seed-bar'},
|
||||
', randomized with seed ',
|
||||
createDom('a', {title: 'randomized with seed ' + order.seed, href: seedHref(order.seed)}, order.seed)
|
||||
);
|
||||
}
|
||||
|
||||
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage, seedBar));
|
||||
|
||||
var errorBarClassName = 'jasmine-bar jasmine-errored';
|
||||
var afterAllMessagePrefix = 'AfterAll ';
|
||||
|
||||
for(i = 0; i < globalFailures.length; i++) {
|
||||
alert.appendChild(createDom('span', {className: errorBarClassName}, globalFailureMessage(globalFailures[i])));
|
||||
}
|
||||
|
||||
function globalFailureMessage(failure) {
|
||||
if (failure.globalErrorType === 'load') {
|
||||
var prefix = 'Error during loading: ' + failure.message;
|
||||
|
||||
if (failure.filename) {
|
||||
return prefix + ' in ' + failure.filename + ' line ' + failure.lineno;
|
||||
} else {
|
||||
return prefix;
|
||||
}
|
||||
} else {
|
||||
return afterAllMessagePrefix + failure.message;
|
||||
}
|
||||
}
|
||||
|
||||
addDeprecationWarnings(doneResult);
|
||||
|
||||
var warningBarClassName = 'jasmine-bar jasmine-warning';
|
||||
for(i = 0; i < deprecationWarnings.length; i++) {
|
||||
var warning = deprecationWarnings[i];
|
||||
alert.appendChild(createDom('span', {className: warningBarClassName}, 'DEPRECATION: ' + warning));
|
||||
}
|
||||
|
||||
var results = find('.jasmine-results');
|
||||
results.appendChild(summary);
|
||||
|
||||
summaryList(stateBuilder.topResults, summary);
|
||||
|
||||
if (failures.length) {
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-spec-list'},
|
||||
createDom('span', {}, 'Spec List | '),
|
||||
createDom('a', {className: 'jasmine-failures-menu', href: '#'}, 'Failures')));
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-failure-list'},
|
||||
createDom('a', {className: 'jasmine-spec-list-menu', href: '#'}, 'Spec List'),
|
||||
createDom('span', {}, ' | Failures ')));
|
||||
|
||||
find('.jasmine-failures-menu').onclick = function() {
|
||||
setMenuModeTo('jasmine-failure-list');
|
||||
};
|
||||
find('.jasmine-spec-list-menu').onclick = function() {
|
||||
setMenuModeTo('jasmine-spec-list');
|
||||
};
|
||||
|
||||
setMenuModeTo('jasmine-failure-list');
|
||||
|
||||
var failureNode = find('.jasmine-failures');
|
||||
for (i = 0; i < failures.length; i++) {
|
||||
failureNode.appendChild(failures[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function failureDom(result) {
|
||||
var failure =
|
||||
createDom('div', {className: 'jasmine-spec-detail jasmine-failed'},
|
||||
failureDescription(result, stateBuilder.currentParent),
|
||||
createDom('div', {className: 'jasmine-messages'})
|
||||
);
|
||||
var messages = failure.childNodes[1];
|
||||
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
var expectation = result.failedExpectations[i];
|
||||
messages.appendChild(createDom('div', {className: 'jasmine-result-message'}, expectation.message));
|
||||
messages.appendChild(createDom('div', {className: 'jasmine-stack-trace'}, expectation.stack));
|
||||
}
|
||||
|
||||
return failure;
|
||||
}
|
||||
|
||||
function summaryList(resultsTree, domParent) {
|
||||
var specListNode;
|
||||
for (var i = 0; i < resultsTree.children.length; i++) {
|
||||
var resultNode = resultsTree.children[i];
|
||||
if (filterSpecs && !hasActiveSpec(resultNode)) {
|
||||
continue;
|
||||
}
|
||||
if (resultNode.type === 'suite') {
|
||||
var suiteListNode = createDom('ul', {className: 'jasmine-suite', id: 'suite-' + resultNode.result.id},
|
||||
createDom('li', {className: 'jasmine-suite-detail jasmine-' + resultNode.result.status},
|
||||
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
|
||||
)
|
||||
);
|
||||
|
||||
summaryList(resultNode, suiteListNode);
|
||||
domParent.appendChild(suiteListNode);
|
||||
}
|
||||
if (resultNode.type === 'spec') {
|
||||
if (domParent.getAttribute('class') !== 'jasmine-specs') {
|
||||
specListNode = createDom('ul', {className: 'jasmine-specs'});
|
||||
domParent.appendChild(specListNode);
|
||||
}
|
||||
var specDescription = resultNode.result.description;
|
||||
if(noExpectations(resultNode.result)) {
|
||||
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
|
||||
}
|
||||
if(resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') {
|
||||
specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason;
|
||||
}
|
||||
specListNode.appendChild(
|
||||
createDom('li', {
|
||||
className: 'jasmine-' + resultNode.result.status,
|
||||
id: 'spec-' + resultNode.result.id
|
||||
},
|
||||
createDom('a', {href: specHref(resultNode.result)}, specDescription)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function optionsMenu(config) {
|
||||
var optionsMenuDom = createDom('div', { className: 'jasmine-run-options' },
|
||||
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
||||
createDom('div', { className: 'jasmine-payload' },
|
||||
createDom('div', { className: 'jasmine-stop-on-failure' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-fail-fast',
|
||||
id: 'jasmine-fail-fast',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-fail-fast' }, 'stop execution on spec failure')),
|
||||
createDom('div', { className: 'jasmine-throw-failures' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-throw',
|
||||
id: 'jasmine-throw-failures',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-throw-failures' }, 'stop spec on expectation failure')),
|
||||
createDom('div', { className: 'jasmine-random-order' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-random',
|
||||
id: 'jasmine-random-order',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order')),
|
||||
createDom('div', { className: 'jasmine-hide-disabled' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-disabled',
|
||||
id: 'jasmine-hide-disabled',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-hide-disabled' }, 'hide disabled tests'))
|
||||
)
|
||||
);
|
||||
|
||||
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
|
||||
failFastCheckbox.checked = config.failFast;
|
||||
failFastCheckbox.onclick = function() {
|
||||
navigateWithNewParam('failFast', !config.failFast);
|
||||
};
|
||||
|
||||
var throwCheckbox = optionsMenuDom.querySelector('#jasmine-throw-failures');
|
||||
throwCheckbox.checked = config.oneFailurePerSpec;
|
||||
throwCheckbox.onclick = function() {
|
||||
navigateWithNewParam('throwFailures', !config.oneFailurePerSpec);
|
||||
};
|
||||
|
||||
var randomCheckbox = optionsMenuDom.querySelector('#jasmine-random-order');
|
||||
randomCheckbox.checked = config.random;
|
||||
randomCheckbox.onclick = function() {
|
||||
navigateWithNewParam('random', !config.random);
|
||||
};
|
||||
|
||||
var hideDisabled = optionsMenuDom.querySelector('#jasmine-hide-disabled');
|
||||
hideDisabled.checked = config.hideDisabled;
|
||||
hideDisabled.onclick = function() {
|
||||
navigateWithNewParam('hideDisabled', !config.hideDisabled);
|
||||
};
|
||||
|
||||
var optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
||||
optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'),
|
||||
isOpen = /\bjasmine-open\b/;
|
||||
|
||||
optionsTrigger.onclick = function() {
|
||||
if (isOpen.test(optionsPayload.className)) {
|
||||
optionsPayload.className = optionsPayload.className.replace(isOpen, '');
|
||||
} else {
|
||||
optionsPayload.className += ' jasmine-open';
|
||||
}
|
||||
};
|
||||
|
||||
return optionsMenuDom;
|
||||
}
|
||||
|
||||
function failureDescription(result, suite) {
|
||||
var wrapper = createDom('div', {className: 'jasmine-description'},
|
||||
createDom('a', {title: result.description, href: specHref(result)}, result.description)
|
||||
);
|
||||
var suiteLink;
|
||||
|
||||
while (suite && suite.parent) {
|
||||
wrapper.insertBefore(createTextNode(' > '), wrapper.firstChild);
|
||||
suiteLink = createDom('a', {href: suiteHref(suite)}, suite.result.description);
|
||||
wrapper.insertBefore(suiteLink, wrapper.firstChild);
|
||||
|
||||
suite = suite.parent;
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
function suiteHref(suite) {
|
||||
var els = [];
|
||||
|
||||
while (suite && suite.parent) {
|
||||
els.unshift(suite.result.description);
|
||||
suite = suite.parent;
|
||||
}
|
||||
|
||||
return addToExistingQueryString('spec', els.join(' '));
|
||||
}
|
||||
|
||||
function addDeprecationWarnings(result) {
|
||||
if (result && result.deprecationWarnings) {
|
||||
for(var i = 0; i < result.deprecationWarnings.length; i++) {
|
||||
var warning = result.deprecationWarnings[i].message;
|
||||
if (!j$.util.arrayContains(warning)) {
|
||||
deprecationWarnings.push(warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function find(selector) {
|
||||
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
|
||||
}
|
||||
|
||||
function clearPrior() {
|
||||
// return the reporter
|
||||
var oldReporter = find('');
|
||||
|
||||
if(oldReporter) {
|
||||
getContainer().removeChild(oldReporter);
|
||||
}
|
||||
}
|
||||
|
||||
function createDom(type, attrs, childrenVarArgs) {
|
||||
var el = createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(createTextNode(child));
|
||||
} else {
|
||||
if (child) {
|
||||
el.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == 'className') {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
function pluralize(singular, count) {
|
||||
var word = (count == 1 ? singular : singular + 's');
|
||||
|
||||
return '' + count + ' ' + word;
|
||||
}
|
||||
|
||||
function specHref(result) {
|
||||
return addToExistingQueryString('spec', result.fullName);
|
||||
}
|
||||
|
||||
function seedHref(seed) {
|
||||
return addToExistingQueryString('seed', seed);
|
||||
}
|
||||
|
||||
function defaultQueryString(key, value) {
|
||||
return '?' + key + '=' + value;
|
||||
}
|
||||
|
||||
function setMenuModeTo(mode) {
|
||||
htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
|
||||
}
|
||||
|
||||
function noExpectations(result) {
|
||||
return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
|
||||
result.status === 'passed';
|
||||
}
|
||||
|
||||
function hasActiveSpec(resultNode) {
|
||||
if (resultNode.type == 'spec' && resultNode.result.status != 'excluded') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (resultNode.type == 'suite') {
|
||||
for (var i = 0, j = resultNode.children.length; i < j; i++) {
|
||||
if (hasActiveSpec(resultNode.children[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return HtmlReporter;
|
||||
};
|
||||
|
||||
jasmineRequire.HtmlSpecFilter = function() {
|
||||
function HtmlSpecFilter(options) {
|
||||
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
var filterPattern = new RegExp(filterString);
|
||||
|
||||
this.matches = function(specName) {
|
||||
return filterPattern.test(specName);
|
||||
};
|
||||
}
|
||||
|
||||
return HtmlSpecFilter;
|
||||
};
|
||||
|
||||
jasmineRequire.ResultsNode = function() {
|
||||
function ResultsNode(result, type, parent) {
|
||||
this.result = result;
|
||||
this.type = type;
|
||||
this.parent = parent;
|
||||
|
||||
this.children = [];
|
||||
|
||||
this.addChild = function(result, type) {
|
||||
this.children.push(new ResultsNode(result, type, this));
|
||||
};
|
||||
|
||||
this.last = function() {
|
||||
return this.children[this.children.length - 1];
|
||||
};
|
||||
|
||||
this.updateResult = function(result) {
|
||||
this.result = result;
|
||||
};
|
||||
}
|
||||
|
||||
return ResultsNode;
|
||||
};
|
||||
|
||||
jasmineRequire.QueryString = function() {
|
||||
function QueryString(options) {
|
||||
|
||||
this.navigateWithNewParam = function(key, value) {
|
||||
options.getWindowLocation().search = this.fullStringWithNewParam(key, value);
|
||||
};
|
||||
|
||||
this.fullStringWithNewParam = function(key, value) {
|
||||
var paramMap = queryStringToParamMap();
|
||||
paramMap[key] = value;
|
||||
return toQueryString(paramMap);
|
||||
};
|
||||
|
||||
this.getParam = function(key) {
|
||||
return queryStringToParamMap()[key];
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function toQueryString(paramMap) {
|
||||
var qStrPairs = [];
|
||||
for (var prop in paramMap) {
|
||||
qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
|
||||
}
|
||||
return '?' + qStrPairs.join('&');
|
||||
}
|
||||
|
||||
function queryStringToParamMap() {
|
||||
var paramStr = options.getWindowLocation().search.substring(1),
|
||||
params = [],
|
||||
paramMap = {};
|
||||
|
||||
if (paramStr.length > 0) {
|
||||
params = paramStr.split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
var value = decodeURIComponent(p[1]);
|
||||
if (value === 'true' || value === 'false') {
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
paramMap[decodeURIComponent(p[0])] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return QueryString;
|
||||
};
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,489 @@
|
||||
/*
|
||||
json2.js
|
||||
2014-02-04
|
||||
|
||||
Public Domain.
|
||||
|
||||
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
||||
|
||||
See http://www.JSON.org/js.html
|
||||
|
||||
|
||||
This code should be minified before deployment.
|
||||
See http://javascript.crockford.com/jsmin.html
|
||||
|
||||
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
|
||||
NOT CONTROL.
|
||||
|
||||
|
||||
This file creates a global JSON object containing two methods: stringify
|
||||
and parse.
|
||||
|
||||
JSON.stringify(value, replacer, space)
|
||||
value any JavaScript value, usually an object or array.
|
||||
|
||||
replacer an optional parameter that determines how object
|
||||
values are stringified for objects. It can be a
|
||||
function or an array of strings.
|
||||
|
||||
space an optional parameter that specifies the indentation
|
||||
of nested structures. If it is omitted, the text will
|
||||
be packed without extra whitespace. If it is a number,
|
||||
it will specify the number of spaces to indent at each
|
||||
level. If it is a string (such as '\t' or ' '),
|
||||
it contains the characters used to indent at each level.
|
||||
|
||||
This method produces a JSON text from a JavaScript value.
|
||||
|
||||
When an object value is found, if the object contains a toJSON
|
||||
method, its toJSON method will be called and the result will be
|
||||
stringified. A toJSON method does not serialize: it returns the
|
||||
value represented by the name/value pair that should be serialized,
|
||||
or undefined if nothing should be serialized. The toJSON method
|
||||
will be passed the key associated with the value, and this will be
|
||||
bound to the value
|
||||
|
||||
For example, this would serialize Dates as ISO strings.
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
return this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z';
|
||||
};
|
||||
|
||||
You can provide an optional replacer method. It will be passed the
|
||||
key and value of each member, with this bound to the containing
|
||||
object. The value that is returned from your method will be
|
||||
serialized. If your method returns undefined, then the member will
|
||||
be excluded from the serialization.
|
||||
|
||||
If the replacer parameter is an array of strings, then it will be
|
||||
used to select the members to be serialized. It filters the results
|
||||
such that only members with keys listed in the replacer array are
|
||||
stringified.
|
||||
|
||||
Values that do not have JSON representations, such as undefined or
|
||||
functions, will not be serialized. Such values in objects will be
|
||||
dropped; in arrays they will be replaced with null. You can use
|
||||
a replacer function to replace those with JSON values.
|
||||
JSON.stringify(undefined) returns undefined.
|
||||
|
||||
The optional space parameter produces a stringification of the
|
||||
value that is filled with line breaks and indentation to make it
|
||||
easier to read.
|
||||
|
||||
If the space parameter is a non-empty string, then that string will
|
||||
be used for indentation. If the space parameter is a number, then
|
||||
the indentation will be that many spaces.
|
||||
|
||||
Example:
|
||||
|
||||
text = JSON.stringify(['e', {pluribus: 'unum'}]);
|
||||
// text is '["e",{"pluribus":"unum"}]'
|
||||
|
||||
|
||||
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
|
||||
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
|
||||
|
||||
text = JSON.stringify([new Date()], function (key, value) {
|
||||
return this[key] instanceof Date ?
|
||||
'Date(' + this[key] + ')' : value;
|
||||
});
|
||||
// text is '["Date(---current time---)"]'
|
||||
|
||||
|
||||
JSON.parse(text, reviver)
|
||||
This method parses a JSON text to produce an object or array.
|
||||
It can throw a SyntaxError exception.
|
||||
|
||||
The optional reviver parameter is a function that can filter and
|
||||
transform the results. It receives each of the keys and values,
|
||||
and its return value is used instead of the original value.
|
||||
If it returns what it received, then the structure is not modified.
|
||||
If it returns undefined then the member is deleted.
|
||||
|
||||
Example:
|
||||
|
||||
// Parse the text. Values that look like ISO date strings will
|
||||
// be converted to Date objects.
|
||||
|
||||
myData = JSON.parse(text, function (key, value) {
|
||||
var a;
|
||||
if (typeof value === 'string') {
|
||||
a =
|
||||
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
|
||||
if (a) {
|
||||
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
|
||||
+a[5], +a[6]));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
|
||||
var d;
|
||||
if (typeof value === 'string' &&
|
||||
value.slice(0, 5) === 'Date(' &&
|
||||
value.slice(-1) === ')') {
|
||||
d = new Date(value.slice(5, -1));
|
||||
if (d) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
|
||||
This is a reference implementation. You are free to copy, modify, or
|
||||
redistribute.
|
||||
*/
|
||||
|
||||
/*jslint evil: true, regexp: true */
|
||||
|
||||
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
||||
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
||||
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
||||
lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
||||
test, toJSON, toString, valueOf
|
||||
*/
|
||||
|
||||
|
||||
// Create a JSON object only if one does not already exist. We create the
|
||||
// methods in a closure to avoid creating global variables.
|
||||
|
||||
if (typeof JSON !== 'object') {
|
||||
JSON = {};
|
||||
}
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
if (typeof Date.prototype.toJSON !== 'function') {
|
||||
|
||||
Date.prototype.toJSON = function () {
|
||||
|
||||
return isFinite(this.valueOf())
|
||||
? this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z'
|
||||
: null;
|
||||
};
|
||||
|
||||
String.prototype.toJSON =
|
||||
Number.prototype.toJSON =
|
||||
Boolean.prototype.toJSON = function () {
|
||||
return this.valueOf();
|
||||
};
|
||||
}
|
||||
|
||||
var cx,
|
||||
escapable,
|
||||
gap,
|
||||
indent,
|
||||
meta,
|
||||
rep;
|
||||
|
||||
|
||||
function quote(string) {
|
||||
|
||||
// If the string contains no control characters, no quote characters, and no
|
||||
// backslash characters, then we can safely slap some quotes around it.
|
||||
// Otherwise we must also replace the offending characters with safe escape
|
||||
// sequences.
|
||||
|
||||
escapable.lastIndex = 0;
|
||||
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
||||
var c = meta[a];
|
||||
return typeof c === 'string'
|
||||
? c
|
||||
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
}) + '"' : '"' + string + '"';
|
||||
}
|
||||
|
||||
|
||||
function str(key, holder) {
|
||||
|
||||
// Produce a string from holder[key].
|
||||
|
||||
var i, // The loop counter.
|
||||
k, // The member key.
|
||||
v, // The member value.
|
||||
length,
|
||||
mind = gap,
|
||||
partial,
|
||||
value = holder[key];
|
||||
|
||||
// If the value has a toJSON method, call it to obtain a replacement value.
|
||||
|
||||
if (value && typeof value === 'object' &&
|
||||
typeof value.toJSON === 'function') {
|
||||
value = value.toJSON(key);
|
||||
}
|
||||
|
||||
// If we were called with a replacer function, then call the replacer to
|
||||
// obtain a replacement value.
|
||||
|
||||
if (typeof rep === 'function') {
|
||||
value = rep.call(holder, key, value);
|
||||
}
|
||||
|
||||
// What happens next depends on the value's type.
|
||||
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
return quote(value);
|
||||
|
||||
case 'number':
|
||||
|
||||
// JSON numbers must be finite. Encode non-finite numbers as null.
|
||||
|
||||
return isFinite(value) ? String(value) : 'null';
|
||||
|
||||
case 'boolean':
|
||||
case 'null':
|
||||
|
||||
// If the value is a boolean or null, convert it to a string. Note:
|
||||
// typeof null does not produce 'null'. The case is included here in
|
||||
// the remote chance that this gets fixed someday.
|
||||
|
||||
return String(value);
|
||||
|
||||
// If the type is 'object', we might be dealing with an object or an array or
|
||||
// null.
|
||||
|
||||
case 'object':
|
||||
|
||||
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
||||
// so watch out for that case.
|
||||
|
||||
if (!value) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
// Make an array to hold the partial results of stringifying this object value.
|
||||
|
||||
gap += indent;
|
||||
partial = [];
|
||||
|
||||
// Is the value an array?
|
||||
|
||||
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
||||
|
||||
// The value is an array. Stringify every element. Use null as a placeholder
|
||||
// for non-JSON values.
|
||||
|
||||
length = value.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
partial[i] = str(i, value) || 'null';
|
||||
}
|
||||
|
||||
// Join all of the elements together, separated with commas, and wrap them in
|
||||
// brackets.
|
||||
|
||||
v = partial.length === 0
|
||||
? '[]'
|
||||
: gap
|
||||
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
|
||||
: '[' + partial.join(',') + ']';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
|
||||
// If the replacer is an array, use it to select the members to be stringified.
|
||||
|
||||
if (rep && typeof rep === 'object') {
|
||||
length = rep.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
if (typeof rep[i] === 'string') {
|
||||
k = rep[i];
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// Otherwise, iterate through all of the keys in the object.
|
||||
|
||||
for (k in value) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Join all of the member texts together, separated with commas,
|
||||
// and wrap them in braces.
|
||||
|
||||
v = partial.length === 0
|
||||
? '{}'
|
||||
: gap
|
||||
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
|
||||
: '{' + partial.join(',') + '}';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
// If the JSON object does not yet have a stringify method, give it one.
|
||||
|
||||
if (typeof JSON.stringify !== 'function') {
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
};
|
||||
JSON.stringify = function (value, replacer, space) {
|
||||
|
||||
// The stringify method takes a value and an optional replacer, and an optional
|
||||
// space parameter, and returns a JSON text. The replacer can be a function
|
||||
// that can replace values, or an array of strings that will select the keys.
|
||||
// A default replacer method can be provided. Use of the space parameter can
|
||||
// produce text that is more easily readable.
|
||||
|
||||
var i;
|
||||
gap = '';
|
||||
indent = '';
|
||||
|
||||
// If the space parameter is a number, make an indent string containing that
|
||||
// many spaces.
|
||||
|
||||
if (typeof space === 'number') {
|
||||
for (i = 0; i < space; i += 1) {
|
||||
indent += ' ';
|
||||
}
|
||||
|
||||
// If the space parameter is a string, it will be used as the indent string.
|
||||
|
||||
} else if (typeof space === 'string') {
|
||||
indent = space;
|
||||
}
|
||||
|
||||
// If there is a replacer, it must be a function or an array.
|
||||
// Otherwise, throw an error.
|
||||
|
||||
rep = replacer;
|
||||
if (replacer && typeof replacer !== 'function' &&
|
||||
(typeof replacer !== 'object' ||
|
||||
typeof replacer.length !== 'number')) {
|
||||
throw new Error('JSON.stringify');
|
||||
}
|
||||
|
||||
// Make a fake root object containing our value under the key of ''.
|
||||
// Return the result of stringifying the value.
|
||||
|
||||
return str('', {'': value});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// If the JSON object does not yet have a parse method, give it one.
|
||||
|
||||
if (typeof JSON.parse !== 'function') {
|
||||
cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
||||
JSON.parse = function (text, reviver) {
|
||||
|
||||
// The parse method takes a text and an optional reviver function, and returns
|
||||
// a JavaScript value if the text is a valid JSON text.
|
||||
|
||||
var j;
|
||||
|
||||
function walk(holder, key) {
|
||||
|
||||
// The walk method is used to recursively walk the resulting structure so
|
||||
// that modifications can be made.
|
||||
|
||||
var k, v, value = holder[key];
|
||||
if (value && typeof value === 'object') {
|
||||
for (k in value) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
||||
v = walk(value, k);
|
||||
if (v !== undefined) {
|
||||
value[k] = v;
|
||||
} else {
|
||||
delete value[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reviver.call(holder, key, value);
|
||||
}
|
||||
|
||||
|
||||
// Parsing happens in four stages. In the first stage, we replace certain
|
||||
// Unicode characters with escape sequences. JavaScript handles many characters
|
||||
// incorrectly, either silently deleting them, or treating them as line endings.
|
||||
|
||||
text = String(text);
|
||||
cx.lastIndex = 0;
|
||||
if (cx.test(text)) {
|
||||
text = text.replace(cx, function (a) {
|
||||
return '\\u' +
|
||||
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
});
|
||||
}
|
||||
|
||||
// In the second stage, we run the text against regular expressions that look
|
||||
// for non-JSON patterns. We are especially concerned with '()' and 'new'
|
||||
// because they can cause invocation, and '=' because it can cause mutation.
|
||||
// But just to be safe, we want to reject all unexpected forms.
|
||||
|
||||
// We split the second stage into 4 regexp operations in order to work around
|
||||
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
||||
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
|
||||
// replace all simple value tokens with ']' characters. Third, we delete all
|
||||
// open brackets that follow a colon or comma or that begin the text. Finally,
|
||||
// we look to see that the remaining characters are only whitespace or ']' or
|
||||
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
|
||||
|
||||
if (/^[\],:{}\s]*$/
|
||||
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
|
||||
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
|
||||
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
||||
|
||||
// In the third stage we use the eval function to compile the text into a
|
||||
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
|
||||
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
||||
// in parens to eliminate the ambiguity.
|
||||
|
||||
j = eval('(' + text + ')');
|
||||
|
||||
// In the optional fourth stage, we recursively walk the new structure, passing
|
||||
// each name/value pair to a reviver function for possible transformation.
|
||||
|
||||
return typeof reviver === 'function'
|
||||
? walk({'': j}, '')
|
||||
: j;
|
||||
}
|
||||
|
||||
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
||||
|
||||
throw new SyntaxError('JSON.parse');
|
||||
};
|
||||
}
|
||||
}());
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (c) 2008-2019 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
module.exports = function(jasmineRequire) {
|
||||
var jasmine = jasmineRequire.core(jasmineRequire);
|
||||
|
||||
var env = jasmine.getEnv({suppressLoadErrors: true});
|
||||
|
||||
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
|
||||
extend(global, jasmineInterface);
|
||||
|
||||
function extend(destination, source) {
|
||||
for (var property in source) destination[property] = source[property];
|
||||
return destination;
|
||||
}
|
||||
|
||||
return jasmine;
|
||||
};
|
@ -1,681 +0,0 @@
|
||||
jasmine.HtmlReporterHelpers = {};
|
||||
|
||||
jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) {
|
||||
el.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
|
||||
var results = child.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
|
||||
var parentDiv = this.dom.summary;
|
||||
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
|
||||
var parent = child[parentSuite];
|
||||
|
||||
if (parent) {
|
||||
if (typeof this.views.suites[parent.id] == 'undefined') {
|
||||
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
|
||||
}
|
||||
parentDiv = this.views.suites[parent.id].element;
|
||||
}
|
||||
|
||||
parentDiv.appendChild(childElement);
|
||||
};
|
||||
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
|
||||
for(var fn in jasmine.HtmlReporterHelpers) {
|
||||
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter = function(_doc) {
|
||||
var self = this;
|
||||
var doc = _doc || window.document;
|
||||
|
||||
var reporterView;
|
||||
|
||||
var dom = {};
|
||||
|
||||
// Jasmine Reporter Public Interface
|
||||
self.logRunningSpecs = false;
|
||||
|
||||
self.reportRunnerStarting = function(runner) {
|
||||
var specs = runner.specs() || [];
|
||||
|
||||
if (specs.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
createReporterDom(runner.env.versionString());
|
||||
doc.body.appendChild(dom.reporter);
|
||||
setExceptionHandling();
|
||||
|
||||
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
|
||||
reporterView.addSpecs(specs, self.specFilter);
|
||||
};
|
||||
|
||||
self.reportRunnerResults = function(runner) {
|
||||
reporterView && reporterView.complete();
|
||||
};
|
||||
|
||||
self.reportSuiteResults = function(suite) {
|
||||
reporterView.suiteComplete(suite);
|
||||
};
|
||||
|
||||
self.reportSpecStarting = function(spec) {
|
||||
if (self.logRunningSpecs) {
|
||||
self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
self.reportSpecResults = function(spec) {
|
||||
reporterView.specComplete(spec);
|
||||
};
|
||||
|
||||
self.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.specFilter = function(spec) {
|
||||
if (!focusedSpecName()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return spec.getFullName().indexOf(focusedSpecName()) === 0;
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
function focusedSpecName() {
|
||||
var specName;
|
||||
|
||||
(function memoizeFocusedSpec() {
|
||||
if (specName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var paramMap = [];
|
||||
var params = jasmine.HtmlReporter.parameters(doc);
|
||||
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
specName = paramMap.spec;
|
||||
})();
|
||||
|
||||
return specName;
|
||||
}
|
||||
|
||||
function createReporterDom(version) {
|
||||
dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
|
||||
dom.banner = self.createDom('div', { className: 'banner' },
|
||||
self.createDom('span', { className: 'title' }, "Jasmine "),
|
||||
self.createDom('span', { className: 'version' }, version)),
|
||||
|
||||
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
|
||||
dom.alert = self.createDom('div', {className: 'alert'},
|
||||
self.createDom('span', { className: 'exceptions' },
|
||||
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
|
||||
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
|
||||
dom.results = self.createDom('div', {className: 'results'},
|
||||
dom.summary = self.createDom('div', { className: 'summary' }),
|
||||
dom.details = self.createDom('div', { id: 'details' }))
|
||||
);
|
||||
}
|
||||
|
||||
function noTryCatch() {
|
||||
return window.location.search.match(/catch=false/);
|
||||
}
|
||||
|
||||
function searchWithCatch() {
|
||||
var params = jasmine.HtmlReporter.parameters(window.document);
|
||||
var removed = false;
|
||||
var i = 0;
|
||||
|
||||
while (!removed && i < params.length) {
|
||||
if (params[i].match(/catch=/)) {
|
||||
params.splice(i, 1);
|
||||
removed = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (jasmine.CATCH_EXCEPTIONS) {
|
||||
params.push("catch=false");
|
||||
}
|
||||
|
||||
return params.join("&");
|
||||
}
|
||||
|
||||
function setExceptionHandling() {
|
||||
var chxCatch = document.getElementById('no_try_catch');
|
||||
|
||||
if (noTryCatch()) {
|
||||
chxCatch.setAttribute('checked', true);
|
||||
jasmine.CATCH_EXCEPTIONS = false;
|
||||
}
|
||||
chxCatch.onclick = function() {
|
||||
window.location.search = searchWithCatch();
|
||||
};
|
||||
}
|
||||
};
|
||||
jasmine.HtmlReporter.parameters = function(doc) {
|
||||
var paramStr = doc.location.search.substring(1);
|
||||
var params = [];
|
||||
|
||||
if (paramStr.length > 0) {
|
||||
params = paramStr.split('&');
|
||||
}
|
||||
return params;
|
||||
}
|
||||
jasmine.HtmlReporter.sectionLink = function(sectionName) {
|
||||
var link = '?';
|
||||
var params = [];
|
||||
|
||||
if (sectionName) {
|
||||
params.push('spec=' + encodeURIComponent(sectionName));
|
||||
}
|
||||
if (!jasmine.CATCH_EXCEPTIONS) {
|
||||
params.push("catch=false");
|
||||
}
|
||||
if (params.length > 0) {
|
||||
link += params.join("&");
|
||||
}
|
||||
|
||||
return link;
|
||||
};
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
|
||||
jasmine.HtmlReporter.ReporterView = function(dom) {
|
||||
this.startedAt = new Date();
|
||||
this.runningSpecCount = 0;
|
||||
this.completeSpecCount = 0;
|
||||
this.passedCount = 0;
|
||||
this.failedCount = 0;
|
||||
this.skippedCount = 0;
|
||||
|
||||
this.createResultsMenu = function() {
|
||||
this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
|
||||
this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
|
||||
' | ',
|
||||
this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
|
||||
|
||||
this.summaryMenuItem.onclick = function() {
|
||||
dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
|
||||
};
|
||||
|
||||
this.detailsMenuItem.onclick = function() {
|
||||
showDetails();
|
||||
};
|
||||
};
|
||||
|
||||
this.addSpecs = function(specs, specFilter) {
|
||||
this.totalSpecCount = specs.length;
|
||||
|
||||
this.views = {
|
||||
specs: {},
|
||||
suites: {}
|
||||
};
|
||||
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
var spec = specs[i];
|
||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
|
||||
if (specFilter(spec)) {
|
||||
this.runningSpecCount++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.specComplete = function(spec) {
|
||||
this.completeSpecCount++;
|
||||
|
||||
if (isUndefined(this.views.specs[spec.id])) {
|
||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
|
||||
}
|
||||
|
||||
var specView = this.views.specs[spec.id];
|
||||
|
||||
switch (specView.status()) {
|
||||
case 'passed':
|
||||
this.passedCount++;
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
this.failedCount++;
|
||||
break;
|
||||
|
||||
case 'skipped':
|
||||
this.skippedCount++;
|
||||
break;
|
||||
}
|
||||
|
||||
specView.refresh();
|
||||
this.refresh();
|
||||
};
|
||||
|
||||
this.suiteComplete = function(suite) {
|
||||
var suiteView = this.views.suites[suite.id];
|
||||
if (isUndefined(suiteView)) {
|
||||
return;
|
||||
}
|
||||
suiteView.refresh();
|
||||
};
|
||||
|
||||
this.refresh = function() {
|
||||
|
||||
if (isUndefined(this.resultsMenu)) {
|
||||
this.createResultsMenu();
|
||||
}
|
||||
|
||||
// currently running UI
|
||||
if (isUndefined(this.runningAlert)) {
|
||||
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
|
||||
dom.alert.appendChild(this.runningAlert);
|
||||
}
|
||||
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
|
||||
|
||||
// skipped specs UI
|
||||
if (isUndefined(this.skippedAlert)) {
|
||||
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
|
||||
}
|
||||
|
||||
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
||||
|
||||
if (this.skippedCount === 1 && isDefined(dom.alert)) {
|
||||
dom.alert.appendChild(this.skippedAlert);
|
||||
}
|
||||
|
||||
// passing specs UI
|
||||
if (isUndefined(this.passedAlert)) {
|
||||
this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
|
||||
}
|
||||
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
|
||||
|
||||
// failing specs UI
|
||||
if (isUndefined(this.failedAlert)) {
|
||||
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
|
||||
}
|
||||
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
|
||||
|
||||
if (this.failedCount === 1 && isDefined(dom.alert)) {
|
||||
dom.alert.appendChild(this.failedAlert);
|
||||
dom.alert.appendChild(this.resultsMenu);
|
||||
}
|
||||
|
||||
// summary info
|
||||
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
|
||||
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
|
||||
};
|
||||
|
||||
this.complete = function() {
|
||||
dom.alert.removeChild(this.runningAlert);
|
||||
|
||||
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
||||
|
||||
if (this.failedCount === 0) {
|
||||
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
|
||||
} else {
|
||||
showDetails();
|
||||
}
|
||||
|
||||
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function showDetails() {
|
||||
if (dom.reporter.className.search(/showDetails/) === -1) {
|
||||
dom.reporter.className += " showDetails";
|
||||
}
|
||||
}
|
||||
|
||||
function isUndefined(obj) {
|
||||
return typeof obj === 'undefined';
|
||||
}
|
||||
|
||||
function isDefined(obj) {
|
||||
return !isUndefined(obj);
|
||||
}
|
||||
|
||||
function specPluralizedFor(count) {
|
||||
var str = count + " spec";
|
||||
if (count > 1) {
|
||||
str += "s"
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
|
||||
|
||||
|
||||
jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
|
||||
this.spec = spec;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
|
||||
this.symbol = this.createDom('li', { className: 'pending' });
|
||||
this.dom.symbolSummary.appendChild(this.symbol);
|
||||
|
||||
this.summary = this.createDom('div', { className: 'specSummary' },
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
|
||||
title: this.spec.getFullName()
|
||||
}, this.spec.description)
|
||||
);
|
||||
|
||||
this.detail = this.createDom('div', { className: 'specDetail' },
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
|
||||
title: this.spec.getFullName()
|
||||
}, this.spec.getFullName())
|
||||
);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.status = function() {
|
||||
return this.getSpecStatus(this.spec);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
|
||||
this.symbol.className = this.status();
|
||||
|
||||
switch (this.status()) {
|
||||
case 'skipped':
|
||||
break;
|
||||
|
||||
case 'passed':
|
||||
this.appendSummaryToSuiteDiv();
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
this.appendSummaryToSuiteDiv();
|
||||
this.appendFailureDetail();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
|
||||
this.summary.className += ' ' + this.status();
|
||||
this.appendToSummary(this.spec, this.summary);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
||||
this.detail.className += ' ' + this.status();
|
||||
|
||||
var resultItems = this.spec.results().getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
this.detail.appendChild(messagesDiv);
|
||||
this.dom.details.appendChild(this.detail);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
|
||||
this.suite = suite;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
|
||||
this.element = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
|
||||
);
|
||||
|
||||
this.appendToSummary(this.suite, this.element);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SuiteView.prototype.status = function() {
|
||||
return this.getSpecStatus(this.suite);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
|
||||
this.element.className += " " + this.status();
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
|
||||
|
||||
/* @deprecated Use jasmine.HtmlReporter instead
|
||||
*/
|
||||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) { el.appendChild(child); }
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
this.createDom('span', { className: 'title' }, "Jasmine"),
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onclick = function(evt) {
|
||||
if (showPassed.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onclick = function(evt) {
|
||||
if (showSkipped.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||
this.runnerDiv.setAttribute("class", className);
|
||||
//do it twice for IE
|
||||
this.runnerDiv.setAttribute("className", className);
|
||||
var specs = runner.specs();
|
||||
var specCount = 0;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
if (this.specFilter(specs[i])) {
|
||||
specCount++;
|
||||
}
|
||||
}
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||
|
||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap.spec) {
|
||||
return true;
|
||||
}
|
||||
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
||||
};
|
@ -1,82 +0,0 @@
|
||||
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
|
||||
|
||||
#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
|
||||
#HTMLReporter a { text-decoration: none; }
|
||||
#HTMLReporter a:hover { text-decoration: underline; }
|
||||
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
|
||||
#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
|
||||
#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
|
||||
#HTMLReporter .version { color: #aaaaaa; }
|
||||
#HTMLReporter .banner { margin-top: 14px; }
|
||||
#HTMLReporter .duration { color: #aaaaaa; float: right; }
|
||||
#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
|
||||
#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
|
||||
#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
|
||||
#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
|
||||
#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
|
||||
#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
|
||||
#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
|
||||
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
|
||||
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
|
||||
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
|
||||
#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
|
||||
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
||||
#HTMLReporter .runningAlert { background-color: #666666; }
|
||||
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
|
||||
#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
|
||||
#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
|
||||
#HTMLReporter .passingAlert { background-color: #a6b779; }
|
||||
#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
|
||||
#HTMLReporter .failingAlert { background-color: #cf867e; }
|
||||
#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
|
||||
#HTMLReporter .results { margin-top: 14px; }
|
||||
#HTMLReporter #details { display: none; }
|
||||
#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
|
||||
#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
|
||||
#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
|
||||
#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
#HTMLReporter.showDetails .summary { display: none; }
|
||||
#HTMLReporter.showDetails #details { display: block; }
|
||||
#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
#HTMLReporter .summary { margin-top: 14px; }
|
||||
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
|
||||
#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
|
||||
#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
|
||||
#HTMLReporter .description + .suite { margin-top: 0; }
|
||||
#HTMLReporter .suite { margin-top: 14px; }
|
||||
#HTMLReporter .suite a { color: #333333; }
|
||||
#HTMLReporter #details .specDetail { margin-bottom: 28px; }
|
||||
#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
|
||||
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
|
||||
#HTMLReporter .resultMessage span.result { display: block; }
|
||||
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
||||
|
||||
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
|
||||
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
|
||||
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
|
||||
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
|
||||
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
|
||||
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
|
||||
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
|
||||
#TrivialReporter .runner.running { background-color: yellow; }
|
||||
#TrivialReporter .options { text-align: right; font-size: .8em; }
|
||||
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
|
||||
#TrivialReporter .suite .suite { margin: 5px; }
|
||||
#TrivialReporter .suite.passed { background-color: #dfd; }
|
||||
#TrivialReporter .suite.failed { background-color: #fdd; }
|
||||
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
|
||||
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
|
||||
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
|
||||
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
|
||||
#TrivialReporter .spec.skipped { background-color: #bbb; }
|
||||
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
|
||||
#TrivialReporter .passed { background-color: #cfc; display: none; }
|
||||
#TrivialReporter .failed { background-color: #fbb; }
|
||||
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
|
||||
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
|
||||
#TrivialReporter .resultMessage .mismatch { color: black; }
|
||||
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
|
||||
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
|
||||
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
|
||||
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
|
||||
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
|
File diff suppressed because it is too large
Load Diff
20
plugins/tiddlywiki/jasmine/files/jasmine/MIT.LICENSE
Normal file
20
plugins/tiddlywiki/jasmine/files/jasmine/MIT.LICENSE
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright (c) 2014-2016 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
283
plugins/tiddlywiki/jasmine/files/jasmine/lib/command.js
Normal file
283
plugins/tiddlywiki/jasmine/files/jasmine/lib/command.js
Normal file
@ -0,0 +1,283 @@
|
||||
var path = require('path'),
|
||||
fs = require('fs');
|
||||
|
||||
exports = module.exports = Command;
|
||||
|
||||
var subCommands = {
|
||||
init: {
|
||||
description: 'initialize jasmine',
|
||||
action: initJasmine
|
||||
},
|
||||
examples: {
|
||||
description: 'install examples',
|
||||
action: installExamples
|
||||
},
|
||||
help: {
|
||||
description: 'show help',
|
||||
action: help,
|
||||
alias: '-h'
|
||||
},
|
||||
version: {
|
||||
description: 'show jasmine and jasmine-core versions',
|
||||
action: version,
|
||||
alias: '-v'
|
||||
}
|
||||
};
|
||||
|
||||
function Command(projectBaseDir, examplesDir, print) {
|
||||
this.projectBaseDir = projectBaseDir;
|
||||
this.specDir = path.join(projectBaseDir, 'spec');
|
||||
|
||||
var command = this;
|
||||
|
||||
this.run = function(jasmine, commands) {
|
||||
setEnvironmentVariables(commands);
|
||||
|
||||
var commandToRun;
|
||||
Object.keys(subCommands).forEach(function(cmd) {
|
||||
var commandObject = subCommands[cmd];
|
||||
if (commands.indexOf(cmd) >= 0) {
|
||||
commandToRun = commandObject;
|
||||
} else if(commandObject.alias && commands.indexOf(commandObject.alias) >= 0) {
|
||||
commandToRun = commandObject;
|
||||
}
|
||||
});
|
||||
|
||||
if (commandToRun) {
|
||||
commandToRun.action({jasmine: jasmine, projectBaseDir: command.projectBaseDir, specDir: command.specDir, examplesDir: examplesDir, print: print});
|
||||
} else {
|
||||
var env = parseOptions(commands);
|
||||
if (env.unknownOptions.length > 0) {
|
||||
process.exitCode = 1;
|
||||
print('Unknown options: ' + env.unknownOptions.join(', '));
|
||||
print('');
|
||||
help({print: print});
|
||||
} else {
|
||||
runJasmine(jasmine, env, print);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function isFileArg(arg) {
|
||||
return arg.indexOf('--') !== 0 && !isEnvironmentVariable(arg);
|
||||
}
|
||||
|
||||
function parseOptions(argv) {
|
||||
var files = [],
|
||||
helpers = [],
|
||||
requires = [],
|
||||
unknownOptions = [],
|
||||
color = process.stdout.isTTY || false,
|
||||
reporter,
|
||||
configPath,
|
||||
filter,
|
||||
stopOnFailure,
|
||||
failFast,
|
||||
random,
|
||||
seed;
|
||||
|
||||
argv.forEach(function(arg) {
|
||||
if (arg === '--no-color') {
|
||||
color = false;
|
||||
} else if (arg === '--color') {
|
||||
color = true;
|
||||
} else if (arg.match("^--filter=")) {
|
||||
filter = arg.match("^--filter=(.*)")[1];
|
||||
} else if (arg.match("^--helper=")) {
|
||||
helpers.push(arg.match("^--helper=(.*)")[1]);
|
||||
} else if (arg.match("^--require=")) {
|
||||
requires.push(arg.match("^--require=(.*)")[1]);
|
||||
} else if (arg.match("^--stop-on-failure=")) {
|
||||
stopOnFailure = arg.match("^--stop-on-failure=(.*)")[1] === 'true';
|
||||
} else if (arg.match("^--fail-fast=")) {
|
||||
failFast = arg.match("^--fail-fast=(.*)")[1] === 'true';
|
||||
} else if (arg.match("^--random=")) {
|
||||
random = arg.match("^--random=(.*)")[1] === 'true';
|
||||
} else if (arg.match("^--seed=")) {
|
||||
seed = arg.match("^--seed=(.*)")[1];
|
||||
} else if (arg.match("^--config=")) {
|
||||
configPath = arg.match("^--config=(.*)")[1];
|
||||
} else if (arg.match("^--reporter=")) {
|
||||
reporter = arg.match("^--reporter=(.*)")[1];
|
||||
} else if (isFileArg(arg)) {
|
||||
files.push(arg);
|
||||
} else if (!isEnvironmentVariable(arg)) {
|
||||
unknownOptions.push(arg);
|
||||
}
|
||||
});
|
||||
return {
|
||||
color: color,
|
||||
configPath: configPath,
|
||||
filter: filter,
|
||||
stopOnFailure: stopOnFailure,
|
||||
failFast: failFast,
|
||||
helpers: helpers,
|
||||
requires: requires,
|
||||
reporter: reporter,
|
||||
files: files,
|
||||
random: random,
|
||||
seed: seed,
|
||||
unknownOptions: unknownOptions
|
||||
};
|
||||
}
|
||||
|
||||
function runJasmine(jasmine, env, print) {
|
||||
jasmine.loadConfigFile(env.configPath || process.env.JASMINE_CONFIG_PATH);
|
||||
if (env.stopOnFailure !== undefined) {
|
||||
jasmine.stopSpecOnExpectationFailure(env.stopOnFailure);
|
||||
}
|
||||
if (env.failFast !== undefined) {
|
||||
jasmine.stopOnSpecFailure(env.failFast);
|
||||
}
|
||||
if (env.seed !== undefined) {
|
||||
jasmine.seed(env.seed);
|
||||
}
|
||||
if (env.random !== undefined) {
|
||||
jasmine.randomizeTests(env.random);
|
||||
}
|
||||
if (env.helpers !== undefined && env.helpers.length) {
|
||||
jasmine.addHelperFiles(env.helpers);
|
||||
}
|
||||
if (env.requires !== undefined && env.requires.length) {
|
||||
jasmine.addRequires(env.requires);
|
||||
}
|
||||
if (env.reporter !== undefined) {
|
||||
try {
|
||||
var Report = require(env.reporter);
|
||||
var reporter = new Report();
|
||||
jasmine.clearReporters();
|
||||
jasmine.addReporter(reporter);
|
||||
} catch(e) {
|
||||
print('failed to register reporter "' + env.reporter + '"');
|
||||
print(e.message);
|
||||
print(e.stack);
|
||||
}
|
||||
}
|
||||
jasmine.showColors(env.color);
|
||||
jasmine.execute(env.files, env.filter);
|
||||
}
|
||||
|
||||
function initJasmine(options) {
|
||||
var print = options.print;
|
||||
var specDir = options.specDir;
|
||||
makeDirStructure(path.join(specDir, 'support/'));
|
||||
if(!fs.existsSync(path.join(specDir, 'support/jasmine.json'))) {
|
||||
fs.writeFileSync(path.join(specDir, 'support/jasmine.json'), fs.readFileSync(path.join(__dirname, '../lib/examples/jasmine.json'), 'utf-8'));
|
||||
}
|
||||
else {
|
||||
print('spec/support/jasmine.json already exists in your project.');
|
||||
}
|
||||
}
|
||||
|
||||
function installExamples(options) {
|
||||
var specDir = options.specDir;
|
||||
var projectBaseDir = options.projectBaseDir;
|
||||
var examplesDir = options.examplesDir;
|
||||
|
||||
makeDirStructure(path.join(specDir, 'support'));
|
||||
makeDirStructure(path.join(specDir, 'jasmine_examples'));
|
||||
makeDirStructure(path.join(specDir, 'helpers', 'jasmine_examples'));
|
||||
makeDirStructure(path.join(projectBaseDir, 'lib', 'jasmine_examples'));
|
||||
|
||||
copyFiles(
|
||||
path.join(examplesDir, 'spec', 'helpers', 'jasmine_examples'),
|
||||
path.join(specDir, 'helpers', 'jasmine_examples'),
|
||||
new RegExp(/[Hh]elper\.js/)
|
||||
);
|
||||
|
||||
copyFiles(
|
||||
path.join(examplesDir, 'lib', 'jasmine_examples'),
|
||||
path.join(projectBaseDir, 'lib', 'jasmine_examples'),
|
||||
new RegExp(/\.js/)
|
||||
);
|
||||
|
||||
copyFiles(
|
||||
path.join(examplesDir, 'spec', 'jasmine_examples'),
|
||||
path.join(specDir, 'jasmine_examples'),
|
||||
new RegExp(/[Ss]pec.js/)
|
||||
);
|
||||
}
|
||||
|
||||
function help(options) {
|
||||
var print = options.print;
|
||||
print('Usage: jasmine [command] [options] [files]');
|
||||
print('');
|
||||
print('Commands:');
|
||||
Object.keys(subCommands).forEach(function(cmd) {
|
||||
var commandNameText = cmd;
|
||||
if(subCommands[cmd].alias) {
|
||||
commandNameText = commandNameText + ',' + subCommands[cmd].alias;
|
||||
}
|
||||
print('%s\t%s', lPad(commandNameText, 10), subCommands[cmd].description);
|
||||
});
|
||||
print('');
|
||||
print('If no command is given, jasmine specs will be run');
|
||||
print('');
|
||||
print('');
|
||||
|
||||
print('Options:');
|
||||
print('%s\tturn off color in spec output', lPad('--no-color', 18));
|
||||
print('%s\tforce turn on color in spec output', lPad('--color', 18));
|
||||
print('%s\tfilter specs to run only those that match the given string', lPad('--filter=', 18));
|
||||
print('%s\tload helper files that match the given string', lPad('--helper=', 18));
|
||||
print('%s\tload module that match the given string', lPad('--require=', 18));
|
||||
print('%s\t[true|false] stop spec execution on expectation failure', lPad('--stop-on-failure=', 18));
|
||||
print('%s\t[true|false] stop Jasmine execution on spec failure', lPad('--fail-fast=', 18));
|
||||
print('%s\tpath to your optional jasmine.json', lPad('--config=', 18));
|
||||
print('%s\tpath to reporter to use instead of the default Jasmine reporter', lPad('--reporter=', 18));
|
||||
print('');
|
||||
print('The given arguments take precedence over options in your jasmine.json');
|
||||
print('The path to your optional jasmine.json can also be configured by setting the JASMINE_CONFIG_PATH environment variable');
|
||||
}
|
||||
|
||||
function version(options) {
|
||||
var print = options.print;
|
||||
print('jasmine v' + require('../package.json').version);
|
||||
print('jasmine-core v' + options.jasmine.coreVersion());
|
||||
}
|
||||
|
||||
function lPad(str, length) {
|
||||
if (str.length >= length) {
|
||||
return str;
|
||||
} else {
|
||||
return lPad(' ' + str, length);
|
||||
}
|
||||
}
|
||||
|
||||
function copyFiles(srcDir, destDir, pattern) {
|
||||
var srcDirFiles = fs.readdirSync(srcDir);
|
||||
srcDirFiles.forEach(function(file) {
|
||||
if (file.search(pattern) !== -1) {
|
||||
fs.writeFileSync(path.join(destDir, file), fs.readFileSync(path.join(srcDir, file)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function makeDirStructure(absolutePath) {
|
||||
var splitPath = absolutePath.split(path.sep);
|
||||
splitPath.forEach(function(dir, index) {
|
||||
if(index > 1) {
|
||||
var fullPath = path.join(splitPath.slice(0, index).join('/'), dir);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
fs.mkdirSync(fullPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function isEnvironmentVariable(command) {
|
||||
var envRegExp = /(.*)=(.*)/;
|
||||
return command.match(envRegExp);
|
||||
}
|
||||
|
||||
function setEnvironmentVariables(commands) {
|
||||
commands.forEach(function (command) {
|
||||
var regExpMatch = isEnvironmentVariable(command);
|
||||
if(regExpMatch) {
|
||||
var key = regExpMatch[1];
|
||||
var value = regExpMatch[2];
|
||||
process.env[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
module.exports = exports = ConsoleSpecFilter;
|
||||
|
||||
function ConsoleSpecFilter(options) {
|
||||
var filterString = options && options.filterString;
|
||||
var filterPattern = new RegExp(filterString);
|
||||
|
||||
this.matches = function(specName) {
|
||||
return filterPattern.test(specName);
|
||||
};
|
||||
}
|
263
plugins/tiddlywiki/jasmine/files/jasmine/lib/jasmine.js
Normal file
263
plugins/tiddlywiki/jasmine/files/jasmine/lib/jasmine.js
Normal file
@ -0,0 +1,263 @@
|
||||
var path = require('path'),
|
||||
util = require('util'),
|
||||
glob = require('glob'),
|
||||
CompletionReporter = require('./reporters/completion_reporter'),
|
||||
ConsoleSpecFilter = require('./filters/console_spec_filter');
|
||||
|
||||
module.exports = Jasmine;
|
||||
module.exports.ConsoleReporter = require('./reporters/console_reporter');
|
||||
|
||||
function Jasmine(options) {
|
||||
options = options || {};
|
||||
var jasmineCore = options.jasmineCore || require('jasmine-core');
|
||||
this.jasmineCorePath = path.join(jasmineCore.files.path, 'jasmine.js');
|
||||
this.jasmine = jasmineCore.boot(jasmineCore);
|
||||
this.projectBaseDir = options.projectBaseDir || path.resolve();
|
||||
this.specDir = '';
|
||||
this.specFiles = [];
|
||||
this.helperFiles = [];
|
||||
this.requires = [];
|
||||
this.env = this.jasmine.getEnv({suppressLoadErrors: true});
|
||||
this.reportersCount = 0;
|
||||
this.completionReporter = new CompletionReporter();
|
||||
this.onCompleteCallbackAdded = false;
|
||||
this.exit = process.exit;
|
||||
this.showingColors = true;
|
||||
this.reporter = new module.exports.ConsoleReporter();
|
||||
this.addReporter(this.reporter);
|
||||
this.defaultReporterConfigured = false;
|
||||
|
||||
var jasmineRunner = this;
|
||||
this.completionReporter.onComplete(function(passed) {
|
||||
jasmineRunner.exitCodeCompletion(passed);
|
||||
});
|
||||
this.checkExit = checkExit(this);
|
||||
|
||||
this.coreVersion = function() {
|
||||
return jasmineCore.version();
|
||||
};
|
||||
}
|
||||
|
||||
Jasmine.prototype.randomizeTests = function(value) {
|
||||
this.env.configure({random: value});
|
||||
};
|
||||
|
||||
Jasmine.prototype.seed = function(value) {
|
||||
this.env.configure({seed: value});
|
||||
};
|
||||
|
||||
Jasmine.prototype.showColors = function(value) {
|
||||
this.showingColors = value;
|
||||
};
|
||||
|
||||
Jasmine.prototype.addSpecFile = function(filePath) {
|
||||
this.specFiles.push(filePath);
|
||||
};
|
||||
|
||||
Jasmine.prototype.addReporter = function(reporter) {
|
||||
this.env.addReporter(reporter);
|
||||
this.reportersCount++;
|
||||
};
|
||||
|
||||
Jasmine.prototype.clearReporters = function() {
|
||||
this.env.clearReporters();
|
||||
this.reportersCount = 0;
|
||||
};
|
||||
|
||||
Jasmine.prototype.provideFallbackReporter = function(reporter) {
|
||||
this.env.provideFallbackReporter(reporter);
|
||||
};
|
||||
|
||||
Jasmine.prototype.configureDefaultReporter = function(options) {
|
||||
options.timer = options.timer || new this.jasmine.Timer();
|
||||
options.print = options.print || function() {
|
||||
process.stdout.write(util.format.apply(this, arguments));
|
||||
};
|
||||
options.showColors = options.hasOwnProperty('showColors') ? options.showColors : true;
|
||||
options.jasmineCorePath = options.jasmineCorePath || this.jasmineCorePath;
|
||||
|
||||
this.reporter.setOptions(options);
|
||||
this.defaultReporterConfigured = true;
|
||||
};
|
||||
|
||||
Jasmine.prototype.addMatchers = function(matchers) {
|
||||
this.env.addMatchers(matchers);
|
||||
};
|
||||
|
||||
Jasmine.prototype.loadSpecs = function() {
|
||||
this.specFiles.forEach(function(file) {
|
||||
require(file);
|
||||
});
|
||||
};
|
||||
|
||||
Jasmine.prototype.loadHelpers = function() {
|
||||
this.helperFiles.forEach(function(file) {
|
||||
require(file);
|
||||
});
|
||||
};
|
||||
|
||||
Jasmine.prototype.loadRequires = function() {
|
||||
this.requires.forEach(function(r) {
|
||||
require(r);
|
||||
});
|
||||
};
|
||||
|
||||
Jasmine.prototype.loadConfigFile = function(configFilePath) {
|
||||
try {
|
||||
var absoluteConfigFilePath = path.resolve(this.projectBaseDir, configFilePath || 'spec/support/jasmine.json');
|
||||
var config = require(absoluteConfigFilePath);
|
||||
this.loadConfig(config);
|
||||
} catch (e) {
|
||||
if(configFilePath || e.code != 'MODULE_NOT_FOUND') { throw e; }
|
||||
}
|
||||
};
|
||||
|
||||
Jasmine.prototype.loadConfig = function(config) {
|
||||
this.specDir = config.spec_dir || this.specDir;
|
||||
|
||||
var configuration = {};
|
||||
|
||||
if (config.stopSpecOnExpectationFailure !== undefined) {
|
||||
configuration.oneFailurePerSpec = config.stopSpecOnExpectationFailure;
|
||||
}
|
||||
|
||||
if (config.stopOnSpecFailure !== undefined) {
|
||||
configuration.failFast = config.stopOnSpecFailure;
|
||||
}
|
||||
|
||||
if (config.random !== undefined) {
|
||||
configuration.random = config.random;
|
||||
}
|
||||
|
||||
if (Object.keys(configuration).length > 0) {
|
||||
this.env.configure(configuration);
|
||||
}
|
||||
|
||||
if(config.helpers) {
|
||||
this.addHelperFiles(config.helpers);
|
||||
}
|
||||
|
||||
if(config.requires) {
|
||||
this.addRequires(config.requires);
|
||||
}
|
||||
|
||||
if(config.spec_files) {
|
||||
this.addSpecFiles(config.spec_files);
|
||||
}
|
||||
};
|
||||
|
||||
Jasmine.prototype.addHelperFiles = addFiles('helperFiles');
|
||||
Jasmine.prototype.addSpecFiles = addFiles('specFiles');
|
||||
|
||||
Jasmine.prototype.addRequires = function(requires) {
|
||||
var jasmineRunner = this;
|
||||
requires.forEach(function(r) {
|
||||
jasmineRunner.requires.push(r);
|
||||
});
|
||||
};
|
||||
|
||||
function addFiles(kind) {
|
||||
return function (files) {
|
||||
var jasmineRunner = this;
|
||||
var fileArr = this[kind];
|
||||
|
||||
var includeFiles = [];
|
||||
var excludeFiles = [];
|
||||
files.forEach(function(file) {
|
||||
if (file.startsWith('!')) {
|
||||
var excludeFile = file.substring(1);
|
||||
if(!(path.isAbsolute && path.isAbsolute(excludeFile))) {
|
||||
excludeFile = path.join(jasmineRunner.projectBaseDir, jasmineRunner.specDir, excludeFile);
|
||||
}
|
||||
|
||||
excludeFiles.push(excludeFile);
|
||||
} else {
|
||||
includeFiles.push(file);
|
||||
}
|
||||
});
|
||||
|
||||
includeFiles.forEach(function(file) {
|
||||
if(!(path.isAbsolute && path.isAbsolute(file))) {
|
||||
file = path.join(jasmineRunner.projectBaseDir, jasmineRunner.specDir, file);
|
||||
}
|
||||
var filePaths = glob.sync(file, { ignore: excludeFiles });
|
||||
filePaths.forEach(function(filePath) {
|
||||
// glob will always output '/' as a segment separator but the fileArr may use \ on windows
|
||||
// fileArr needs to be checked for both versions
|
||||
if(fileArr.indexOf(filePath) === -1 && fileArr.indexOf(path.normalize(filePath)) === -1) {
|
||||
fileArr.push(filePath);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Jasmine.prototype.onComplete = function(onCompleteCallback) {
|
||||
this.completionReporter.onComplete(onCompleteCallback);
|
||||
};
|
||||
|
||||
Jasmine.prototype.stopSpecOnExpectationFailure = function(value) {
|
||||
this.env.configure({oneFailurePerSpec: value});
|
||||
};
|
||||
|
||||
Jasmine.prototype.stopOnSpecFailure = function(value) {
|
||||
this.env.configure({failFast: value});
|
||||
};
|
||||
|
||||
Jasmine.prototype.exitCodeCompletion = function(passed) {
|
||||
var jasmineRunner = this;
|
||||
var streams = [process.stdout, process.stderr];
|
||||
var writesToWait = streams.length;
|
||||
streams.forEach(function(stream) {
|
||||
stream.write('', null, exitIfAllStreamsCompleted);
|
||||
});
|
||||
function exitIfAllStreamsCompleted() {
|
||||
writesToWait--;
|
||||
if (writesToWait === 0) {
|
||||
if(passed) {
|
||||
jasmineRunner.exit(0);
|
||||
}
|
||||
else {
|
||||
jasmineRunner.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var checkExit = function(jasmineRunner) {
|
||||
return function() {
|
||||
if (!jasmineRunner.completionReporter.isComplete()) {
|
||||
process.exitCode = 4;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Jasmine.prototype.execute = function(files, filterString) {
|
||||
this.completionReporter.exitHandler = this.checkExit;
|
||||
|
||||
this.loadRequires();
|
||||
this.loadHelpers();
|
||||
if (!this.defaultReporterConfigured) {
|
||||
this.configureDefaultReporter({ showColors: this.showingColors });
|
||||
}
|
||||
|
||||
if(filterString) {
|
||||
var specFilter = new ConsoleSpecFilter({
|
||||
filterString: filterString
|
||||
});
|
||||
this.env.configure({specFilter: function(spec) {
|
||||
return specFilter.matches(spec.getFullName());
|
||||
}});
|
||||
}
|
||||
|
||||
if (files && files.length > 0) {
|
||||
this.specDir = '';
|
||||
this.specFiles = [];
|
||||
this.addSpecFiles(files);
|
||||
}
|
||||
|
||||
this.loadSpecs();
|
||||
|
||||
this.addReporter(this.completionReporter);
|
||||
this.env.execute();
|
||||
};
|
@ -0,0 +1,29 @@
|
||||
module.exports = function() {
|
||||
var onCompleteCallback = function() {};
|
||||
var completed = false;
|
||||
|
||||
this.onComplete = function(callback) {
|
||||
onCompleteCallback = callback;
|
||||
};
|
||||
|
||||
this.jasmineStarted = function() {
|
||||
if (this.exitHandler) {
|
||||
process.on('exit', this.exitHandler);
|
||||
}
|
||||
};
|
||||
|
||||
this.jasmineDone = function(result) {
|
||||
completed = true;
|
||||
if (this.exitHandler) {
|
||||
process.removeListener('exit', this.exitHandler);
|
||||
}
|
||||
|
||||
onCompleteCallback(result.overallStatus === 'passed');
|
||||
};
|
||||
|
||||
this.isComplete = function() {
|
||||
return completed;
|
||||
};
|
||||
|
||||
this.exitHandler = null;
|
||||
};
|
@ -0,0 +1,232 @@
|
||||
module.exports = exports = ConsoleReporter;
|
||||
|
||||
var noopTimer = {
|
||||
start: function(){},
|
||||
elapsed: function(){ return 0; }
|
||||
};
|
||||
|
||||
function ConsoleReporter() {
|
||||
var print = function() {},
|
||||
showColors = false,
|
||||
timer = noopTimer,
|
||||
jasmineCorePath = null,
|
||||
specCount,
|
||||
executableSpecCount,
|
||||
failureCount,
|
||||
failedSpecs = [],
|
||||
pendingSpecs = [],
|
||||
ansi = {
|
||||
green: '\x1B[32m',
|
||||
red: '\x1B[31m',
|
||||
yellow: '\x1B[33m',
|
||||
none: '\x1B[0m'
|
||||
},
|
||||
failedSuites = [],
|
||||
stackFilter = defaultStackFilter;
|
||||
|
||||
this.setOptions = function(options) {
|
||||
if (options.print) {
|
||||
print = options.print;
|
||||
}
|
||||
showColors = options.showColors || false;
|
||||
if (options.timer) {
|
||||
timer = options.timer;
|
||||
}
|
||||
if (options.jasmineCorePath) {
|
||||
jasmineCorePath = options.jasmineCorePath;
|
||||
}
|
||||
if (options.stackFilter) {
|
||||
stackFilter = options.stackFilter;
|
||||
}
|
||||
};
|
||||
|
||||
this.jasmineStarted = function(options) {
|
||||
specCount = 0;
|
||||
executableSpecCount = 0;
|
||||
failureCount = 0;
|
||||
if (options && options.order && options.order.random) {
|
||||
print('Randomized with seed ' + options.order.seed);
|
||||
printNewline();
|
||||
}
|
||||
print('Started');
|
||||
printNewline();
|
||||
timer.start();
|
||||
};
|
||||
|
||||
this.jasmineDone = function(result) {
|
||||
printNewline();
|
||||
printNewline();
|
||||
if(failedSpecs.length > 0) {
|
||||
print('Failures:');
|
||||
}
|
||||
for (var i = 0; i < failedSpecs.length; i++) {
|
||||
specFailureDetails(failedSpecs[i], i + 1);
|
||||
}
|
||||
|
||||
for(i = 0; i < failedSuites.length; i++) {
|
||||
suiteFailureDetails(failedSuites[i]);
|
||||
}
|
||||
|
||||
if (result && result.failedExpectations && result.failedExpectations.length > 0) {
|
||||
suiteFailureDetails(result);
|
||||
}
|
||||
|
||||
if (pendingSpecs.length > 0) {
|
||||
print("Pending:");
|
||||
}
|
||||
for(i = 0; i < pendingSpecs.length; i++) {
|
||||
pendingSpecDetails(pendingSpecs[i], i + 1);
|
||||
}
|
||||
|
||||
if(specCount > 0) {
|
||||
printNewline();
|
||||
|
||||
if(executableSpecCount !== specCount) {
|
||||
print('Ran ' + executableSpecCount + ' of ' + specCount + plural(' spec', specCount));
|
||||
printNewline();
|
||||
}
|
||||
var specCounts = executableSpecCount + ' ' + plural('spec', executableSpecCount) + ', ' +
|
||||
failureCount + ' ' + plural('failure', failureCount);
|
||||
|
||||
if (pendingSpecs.length) {
|
||||
specCounts += ', ' + pendingSpecs.length + ' pending ' + plural('spec', pendingSpecs.length);
|
||||
}
|
||||
|
||||
print(specCounts);
|
||||
} else {
|
||||
print('No specs found');
|
||||
}
|
||||
|
||||
printNewline();
|
||||
var seconds = timer.elapsed() / 1000;
|
||||
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
||||
printNewline();
|
||||
|
||||
if (result && result.overallStatus === 'incomplete') {
|
||||
print('Incomplete: ' + result.incompleteReason);
|
||||
printNewline();
|
||||
}
|
||||
|
||||
if (result && result.order && result.order.random) {
|
||||
print('Randomized with seed ' + result.order.seed);
|
||||
print(' (jasmine --random=true --seed=' + result.order.seed + ')');
|
||||
printNewline();
|
||||
}
|
||||
};
|
||||
|
||||
this.specDone = function(result) {
|
||||
specCount++;
|
||||
|
||||
if (result.status == 'pending') {
|
||||
pendingSpecs.push(result);
|
||||
executableSpecCount++;
|
||||
print(colored('yellow', '*'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status == 'passed') {
|
||||
executableSpecCount++;
|
||||
print(colored('green', '.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status == 'failed') {
|
||||
failureCount++;
|
||||
failedSpecs.push(result);
|
||||
executableSpecCount++;
|
||||
print(colored('red', 'F'));
|
||||
}
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {
|
||||
if (result.failedExpectations && result.failedExpectations.length > 0) {
|
||||
failureCount++;
|
||||
failedSuites.push(result);
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function printNewline() {
|
||||
print('\n');
|
||||
}
|
||||
|
||||
function colored(color, str) {
|
||||
return showColors ? (ansi[color] + str + ansi.none) : str;
|
||||
}
|
||||
|
||||
function plural(str, count) {
|
||||
return count == 1 ? str : str + 's';
|
||||
}
|
||||
|
||||
function repeat(thing, times) {
|
||||
var arr = [];
|
||||
for (var i = 0; i < times; i++) {
|
||||
arr.push(thing);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function indent(str, spaces) {
|
||||
var lines = (str || '').split('\n');
|
||||
var newArr = [];
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
newArr.push(repeat(' ', spaces).join('') + lines[i]);
|
||||
}
|
||||
return newArr.join('\n');
|
||||
}
|
||||
|
||||
function defaultStackFilter(stack) {
|
||||
if (!stack) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var filteredStack = stack.split('\n').filter(function(stackLine) {
|
||||
return stackLine.indexOf(jasmineCorePath) === -1;
|
||||
}).join('\n');
|
||||
return filteredStack;
|
||||
}
|
||||
|
||||
function specFailureDetails(result, failedSpecNumber) {
|
||||
printNewline();
|
||||
print(failedSpecNumber + ') ');
|
||||
print(result.fullName);
|
||||
printFailedExpectations(result);
|
||||
}
|
||||
|
||||
function suiteFailureDetails(result) {
|
||||
printNewline();
|
||||
print('Suite error: ' + result.fullName);
|
||||
printFailedExpectations(result);
|
||||
}
|
||||
|
||||
function printFailedExpectations(result) {
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
var failedExpectation = result.failedExpectations[i];
|
||||
printNewline();
|
||||
print(indent('Message:', 2));
|
||||
printNewline();
|
||||
print(colored('red', indent(failedExpectation.message, 4)));
|
||||
printNewline();
|
||||
print(indent('Stack:', 2));
|
||||
printNewline();
|
||||
print(indent(stackFilter(failedExpectation.stack), 4));
|
||||
}
|
||||
|
||||
printNewline();
|
||||
}
|
||||
|
||||
function pendingSpecDetails(result, pendingSpecNumber) {
|
||||
printNewline();
|
||||
printNewline();
|
||||
print(pendingSpecNumber + ') ');
|
||||
print(result.fullName);
|
||||
printNewline();
|
||||
var pendingReason = "No reason given";
|
||||
if (result.pendingReason && result.pendingReason !== '') {
|
||||
pendingReason = result.pendingReason;
|
||||
}
|
||||
print(indent(colored('yellow', pendingReason), 2));
|
||||
printNewline();
|
||||
}
|
||||
}
|
@ -1,276 +0,0 @@
|
||||
(function() {
|
||||
//
|
||||
// Imports
|
||||
//
|
||||
var util;
|
||||
try {
|
||||
util = require('util')
|
||||
} catch(e) {
|
||||
util = require('sys')
|
||||
}
|
||||
|
||||
var jasmineNode = {};
|
||||
//
|
||||
// Helpers
|
||||
//
|
||||
function noop() {}
|
||||
|
||||
|
||||
jasmineNode.TerminalReporter = function(config) {
|
||||
this.print_ = config.print || util.print;
|
||||
this.color_ = config.color ? this.ANSIColors : this.NoColors;
|
||||
|
||||
this.started_ = false;
|
||||
this.finished_ = false;
|
||||
|
||||
this.callback_ = config.onComplete || false
|
||||
|
||||
this.suites_ = [];
|
||||
this.specResults_ = {};
|
||||
this.failures_ = [];
|
||||
this.includeStackTrace_ = config.includeStackTrace === false ? false : true;
|
||||
}
|
||||
|
||||
|
||||
jasmineNode.TerminalReporter.prototype = {
|
||||
reportRunnerStarting: function(runner) {
|
||||
this.started_ = true;
|
||||
this.startedAt = new Date();
|
||||
var suites = runner.topLevelSuites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
this.suites_.push(this.summarize_(suite));
|
||||
}
|
||||
},
|
||||
|
||||
ANSIColors: {
|
||||
pass: function() { return '\033[32m'; }, // Green
|
||||
fail: function() { return '\033[31m'; }, // Red
|
||||
neutral: function() { return '\033[0m'; } // Normal
|
||||
},
|
||||
|
||||
NoColors: {
|
||||
pass: function() { return ''; },
|
||||
fail: function() { return ''; },
|
||||
neutral: function() { return ''; }
|
||||
},
|
||||
|
||||
summarize_: function(suiteOrSpec) {
|
||||
var isSuite = suiteOrSpec instanceof jasmine.Suite;
|
||||
|
||||
// We could use a separate object for suite and spec
|
||||
var summary = {
|
||||
id: suiteOrSpec.id,
|
||||
name: suiteOrSpec.description,
|
||||
type: isSuite? 'suite' : 'spec',
|
||||
suiteNestingLevel: 0,
|
||||
children: []
|
||||
};
|
||||
|
||||
if (isSuite) {
|
||||
var calculateNestingLevel = function(examinedSuite) {
|
||||
var nestingLevel = 0;
|
||||
while (examinedSuite.parentSuite !== null) {
|
||||
nestingLevel += 1;
|
||||
examinedSuite = examinedSuite.parentSuite;
|
||||
}
|
||||
return nestingLevel;
|
||||
};
|
||||
|
||||
summary.suiteNestingLevel = calculateNestingLevel(suiteOrSpec);
|
||||
|
||||
var children = suiteOrSpec.children();
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
summary.children.push(this.summarize_(children[i]));
|
||||
}
|
||||
}
|
||||
|
||||
return summary;
|
||||
},
|
||||
|
||||
// This is heavily influenced by Jasmine's Html/Trivial Reporter
|
||||
reportRunnerResults: function(runner) {
|
||||
this.reportFailures_();
|
||||
|
||||
var results = runner.results();
|
||||
var resultColor = (results.failedCount > 0) ? this.color_.fail() : this.color_.pass();
|
||||
|
||||
var specs = runner.specs();
|
||||
var specCount = specs.length;
|
||||
|
||||
var message = "\n\nFinished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + " seconds";
|
||||
this.printLine_(message);
|
||||
|
||||
// This is what jasmine-html.js has
|
||||
//message = "" + specCount + " spec" + ( specCount === 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount === 1) ? "" : "s");
|
||||
|
||||
this.printLine_(this.stringWithColor_(this.printRunnerResults_(runner), resultColor));
|
||||
|
||||
this.finished_ = true;
|
||||
if(this.callback_) { this.callback_(runner); }
|
||||
},
|
||||
|
||||
reportFailures_: function() {
|
||||
if (this.failures_.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var indent = ' ', failure;
|
||||
this.printLine_('\n');
|
||||
|
||||
this.print_('Failures:');
|
||||
|
||||
for (var i = 0; i < this.failures_.length; i++) {
|
||||
failure = this.failures_[i];
|
||||
this.printLine_('\n');
|
||||
this.printLine_(' ' + (i + 1) + ') ' + failure.spec);
|
||||
this.printLine_(' Message:');
|
||||
this.printLine_(' ' + this.stringWithColor_(failure.message, this.color_.fail()));
|
||||
if (this.includeStackTrace_) {
|
||||
this.printLine_(' Stacktrace:');
|
||||
this.print_(' ' + failure.stackTrace);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
// Not used in this context
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
var result = spec.results();
|
||||
var msg = '';
|
||||
if (result.passed()) {
|
||||
msg = this.stringWithColor_('.', this.color_.pass());
|
||||
// } else if (result.skipped) { TODO: Research why "result.skipped" returns false when "xit" is called on a spec?
|
||||
// msg = (colors) ? (ansi.yellow + '*' + ansi.none) : '*';
|
||||
} else {
|
||||
msg = this.stringWithColor_('F', this.color_.fail());
|
||||
this.addFailureToFailures_(spec);
|
||||
}
|
||||
this.spec_results += msg;
|
||||
this.print_(msg);
|
||||
},
|
||||
|
||||
addFailureToFailures_: function(spec) {
|
||||
var result = spec.results();
|
||||
var failureItem = null;
|
||||
|
||||
var items_length = result.items_.length;
|
||||
for (var i = 0; i < items_length; i++) {
|
||||
if (result.items_[i].passed_ === false) {
|
||||
failureItem = result.items_[i];
|
||||
|
||||
var failure = {
|
||||
spec: spec.suite.getFullName() + " " + spec.description,
|
||||
message: failureItem.message,
|
||||
stackTrace: failureItem.trace.stack
|
||||
}
|
||||
|
||||
this.failures_.push(failure);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
printRunnerResults_: function(runner){
|
||||
var results = runner.results();
|
||||
var specs = runner.specs();
|
||||
var msg = '';
|
||||
msg += specs.length + ' test' + ((specs.length === 1) ? '' : 's') + ', ';
|
||||
msg += results.totalCount + ' assertion' + ((results.totalCount === 1) ? '' : 's') + ', ';
|
||||
msg += results.failedCount + ' failure' + ((results.failedCount === 1) ? '' : 's') + '\n';
|
||||
return msg;
|
||||
},
|
||||
|
||||
// Helper Methods //
|
||||
stringWithColor_: function(stringValue, color) {
|
||||
return (color || this.color_.neutral()) + stringValue + this.color_.neutral();
|
||||
},
|
||||
|
||||
printLine_: function(stringValue) {
|
||||
this.print_(stringValue);
|
||||
this.print_('\n');
|
||||
}
|
||||
};
|
||||
|
||||
// ***************************************************************
|
||||
// TerminalVerboseReporter uses the TerminalReporter's constructor
|
||||
// ***************************************************************
|
||||
jasmineNode.TerminalVerboseReporter = function(config) {
|
||||
jasmineNode.TerminalReporter.call(this, config);
|
||||
// The extra field in this object
|
||||
this.indent_ = 0;
|
||||
}
|
||||
|
||||
|
||||
jasmineNode.TerminalVerboseReporter.prototype = {
|
||||
reportSpecResults: function(spec) {
|
||||
if (spec.results().failedCount > 0) {
|
||||
this.addFailureToFailures_(spec);
|
||||
}
|
||||
|
||||
this.specResults_[spec.id] = {
|
||||
messages: spec.results().getItems(),
|
||||
result: spec.results().failedCount > 0 ? 'failed' : 'passed'
|
||||
};
|
||||
},
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
var messages = new Array();
|
||||
this.buildMessagesFromResults_(messages, this.suites_);
|
||||
|
||||
var messages_length = messages.length;
|
||||
for (var i = 0; i < messages_length-1; i++) {
|
||||
this.printLine_(messages[i]);
|
||||
}
|
||||
|
||||
this.print_(messages[messages_length-1]);
|
||||
|
||||
// Call the parent object's method
|
||||
jasmineNode.TerminalReporter.prototype.reportRunnerResults.call(this, runner);
|
||||
},
|
||||
|
||||
buildMessagesFromResults_: function(messages, results, depth) {
|
||||
var element, specResult, specIndentSpaces, msg = '';
|
||||
depth = (depth === undefined) ? 0 : depth;
|
||||
|
||||
var results_length = results.length;
|
||||
for (var i = 0; i < results_length; i++) {
|
||||
element = results[i];
|
||||
|
||||
if (element.type === 'spec') {
|
||||
specResult = this.specResults_[element.id.toString()];
|
||||
|
||||
if (specResult.result === 'passed') {
|
||||
msg = this.stringWithColor_(this.indentMessage_(element.name, depth), this.color_.pass());
|
||||
} else {
|
||||
msg = this.stringWithColor_(this.indentMessage_(element.name, depth), this.color_.fail());
|
||||
}
|
||||
|
||||
messages.push(msg);
|
||||
} else {
|
||||
messages.push('');
|
||||
messages.push(this.indentMessage_(element.name, depth));
|
||||
}
|
||||
|
||||
this.buildMessagesFromResults_(messages, element.children, depth + 2);
|
||||
}
|
||||
},
|
||||
|
||||
indentMessage_: function(message, indentCount) {
|
||||
var _indent = '';
|
||||
for (var i = 0; i < indentCount; i++) {
|
||||
_indent += ' ';
|
||||
}
|
||||
return (_indent + message);
|
||||
}
|
||||
};
|
||||
|
||||
// Inherit from TerminalReporter
|
||||
jasmineNode.TerminalVerboseReporter.prototype.__proto__ = jasmineNode.TerminalReporter.prototype;
|
||||
|
||||
//
|
||||
// Exports
|
||||
//
|
||||
exports.jasmineNode = jasmineNode;
|
||||
})();
|
@ -1,35 +1,58 @@
|
||||
{
|
||||
"tiddlers": [
|
||||
"directories": [
|
||||
{
|
||||
"file": "jasmine-html.js",
|
||||
"path": "jasmine/lib",
|
||||
"filesRegExp": "^.*\\.js$",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": "$:/plugins/tiddlywiki/jasmine/jasmine-html.js",
|
||||
"module-type": "library",
|
||||
"global-module": "true"
|
||||
"title": {"source": "filename", "prefix": "$:/plugins/tiddlywiki/jasmine/jasmine/"},
|
||||
"module-type": "library"
|
||||
}
|
||||
},{
|
||||
"file": "jasmine.css",
|
||||
},
|
||||
{
|
||||
"path": "jasmine/lib/filters",
|
||||
"filesRegExp": "^.*\\.js$",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": {"source": "filename", "prefix": "$:/plugins/tiddlywiki/jasmine/jasmine/filters/"},
|
||||
"module-type": "library"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "jasmine/lib/reporters",
|
||||
"filesRegExp": "^.*\\.js$",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": {"source": "filename", "prefix": "$:/plugins/tiddlywiki/jasmine/jasmine/reporters/"},
|
||||
"module-type": "library"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "jasmine-core/lib",
|
||||
"filesRegExp": "^.*\\.js$",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": {"source": "filename", "prefix": "$:/plugins/tiddlywiki/jasmine/jasmine-core/"},
|
||||
"module-type": "library"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "jasmine-core/lib/jasmine-core",
|
||||
"filesRegExp": "^.*\\.js$",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": {"source": "filename", "prefix": "$:/plugins/tiddlywiki/jasmine/jasmine-core/jasmine-core/"},
|
||||
"module-type": "library"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "jasmine-core/lib/jasmine-core",
|
||||
"filesRegExp": "^.*\\.css$",
|
||||
"fields": {
|
||||
"type": "text/css",
|
||||
"title": "$:/plugins/tiddlywiki/jasmine/jasmine.css",
|
||||
"title": {"source": "filename", "prefix": "$:/plugins/tiddlywiki/jasmine/jasmine-core/jasmine-core/"},
|
||||
"tags": "[[$:/tags/Stylesheet]]"
|
||||
}
|
||||
},{
|
||||
"file": "jasmine.js",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": "$:/plugins/tiddlywiki/jasmine/jasmine.js",
|
||||
"module-type": "library"
|
||||
},
|
||||
"prefix": "var window = undefined; /* Prepended to the main jasmine source file to force it into commonjs mode */\n"
|
||||
},{
|
||||
"file": "reporter.js",
|
||||
"fields": {
|
||||
"type": "application/javascript",
|
||||
"title": "$:/plugins/tiddlywiki/jasmine/reporter.js",
|
||||
"module-type": "library"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -18,69 +18,99 @@ var TEST_TIDDLER_FILTER = "[type[application/javascript]tag[$:/tags/test-spec]]"
|
||||
Startup function for running tests
|
||||
*/
|
||||
exports.startup = function() {
|
||||
// Get the Jasmine exports
|
||||
var jasmine = $tw.modules.execute("$:/plugins/tiddlywiki/jasmine/jasmine.js");
|
||||
// Add our other context variables
|
||||
var context = $tw.utils.extend({},jasmine,{
|
||||
console: console,
|
||||
setInterval: setInterval,
|
||||
clearInterval: clearInterval,
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
exports: {},
|
||||
$tw: $tw
|
||||
});
|
||||
// Prepare the Jasmine environment
|
||||
var jasmineEnv = jasmine.jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
// Execute the appropriate reporter
|
||||
var reporterTitle = $tw.browser ? "$:/plugins/tiddlywiki/jasmine/jasmine-html.js" : "$:/plugins/tiddlywiki/jasmine/reporter.js";
|
||||
context.require = function(moduleTitle) {
|
||||
return $tw.modules.execute(moduleTitle,reporterTitle);
|
||||
// Set up a shared context object.
|
||||
var context = {
|
||||
console: console,
|
||||
setInterval: setInterval,
|
||||
clearInterval: clearInterval,
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout,
|
||||
$tw: $tw
|
||||
};
|
||||
var code = $tw.wiki.getTiddlerText(reporterTitle,""),
|
||||
reporterExports = $tw.utils.evalSandboxed(code,context,reporterTitle);
|
||||
// Link the reporter into jasmine
|
||||
if($tw.browser) {
|
||||
var htmlReporter = new jasmine.jasmine.HtmlReporter();
|
||||
jasmineEnv.addReporter(htmlReporter);
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return htmlReporter.specFilter(spec);
|
||||
};
|
||||
} else {
|
||||
// The HTMLReporter links itself into the jasmine object automatically, but we have to manually add the node reporter
|
||||
jasmine.jasmine.TerminalVerboseReporter = reporterExports.jasmineNode.TerminalVerboseReporter;
|
||||
jasmine.jasmine.TerminalReporter = reporterExports.jasmineNode.TerminalReporter;
|
||||
jasmineEnv.addReporter(new jasmine.jasmine.TerminalVerboseReporter({
|
||||
print: require("util").print,
|
||||
color: true,
|
||||
includeStackTrace: true
|
||||
}));
|
||||
}
|
||||
// Add a reporter that exits with an error code if any tests failed
|
||||
jasmineEnv.addReporter({
|
||||
reportRunnerResults: function(runner) {
|
||||
var c = runner.results().failedCount;
|
||||
if(c > 0) {
|
||||
console.log("Exitting with test failure count: ",c);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
// Iterate through all the test modules
|
||||
var tests = $tw.wiki.filterTiddlers(TEST_TIDDLER_FILTER);
|
||||
$tw.utils.each(tests,function(title,index) {
|
||||
// Get the test specification code
|
||||
// The `global` property is needed in two places:
|
||||
// 1. jasmine-core/node_boot.js: extends the global object with jasmine interface.
|
||||
// 2. jasmine-core/jasmine.js: when it's loaded, if it determines that it's
|
||||
// running in a commonjs environment and `global` is undefined, it will set
|
||||
// `jasmineGlobal`, its internal reference to the global object, to {},
|
||||
// which is not what we want. Alternatively, the `jasmine.getEnv()` API allows
|
||||
// you to pass in a `global` object, but the boot scripts we use don't allow
|
||||
// the caller to customize the `.getEnv()` call. We'd rather use the boot scripts
|
||||
// as-is than duplicating them in order to do minor tweaks.
|
||||
//
|
||||
// We need this `$tw.browser ?` conditional because:
|
||||
// 1. In a browser environment, 'jasmine-core/jasmine.js' calls `setTimeout` like
|
||||
// `setTimeout.apply(jasmineGlobal, ...)`; the browser throws an "illegal invocation"
|
||||
// unless `jasmineGlobal` is the right context object, which is `window`.
|
||||
// 2. In Node.js, there is no `window` object.
|
||||
// Further more, we don't have access to the `global` object when this code
|
||||
// is executed, so we use the `context` object instead.
|
||||
context.global = $tw.browser ? window : context;
|
||||
|
||||
function evalInContext(title) {
|
||||
var code = $tw.wiki.getTiddlerText(title,"");
|
||||
// Add a require handler
|
||||
var _exports = {};
|
||||
context.exports = _exports;
|
||||
context.module = {exports: _exports};
|
||||
context.require = function(moduleTitle) {
|
||||
// mock out the 'glob' module required in
|
||||
// "$:/plugins/tiddlywiki/jasmine/jasmine/jasmine.js"
|
||||
if (moduleTitle === "glob") {
|
||||
return {};
|
||||
}
|
||||
return $tw.modules.execute(moduleTitle,title);
|
||||
};
|
||||
// Execute the test code with the context variables
|
||||
$tw.utils.evalSandboxed(code,context,title);
|
||||
var contextExports = $tw.utils.evalSandboxed(code,context,title);
|
||||
// jasmine/jasmine.js assigns directly to `module.exports`: check
|
||||
// for it first.
|
||||
return context.module.exports || contextExports;
|
||||
}
|
||||
|
||||
// Get the core Jasmine exports
|
||||
var jasmineCore = evalInContext("$:/plugins/tiddlywiki/jasmine/jasmine-core/jasmine-core/jasmine.js");
|
||||
// Get the Jasmine instance and configure reporters
|
||||
var jasmine;
|
||||
if($tw.browser) {
|
||||
window.jasmineRequire = jasmineCore;
|
||||
$tw.modules.execute("$:/plugins/tiddlywiki/jasmine/jasmine-core/jasmine-core/jasmine-html.js");
|
||||
$tw.modules.execute("$:/plugins/tiddlywiki/jasmine/jasmine-core/jasmine-core/boot.js");
|
||||
jasmine = window.jasmine;
|
||||
} else {
|
||||
// We load 'jasmine-core/jasmine.js' above instead of the
|
||||
// main script 'jasmine-core/jasmine-core.js', which is what's loaded
|
||||
// when you run `require('jasmine-core')` in a Node.js environment.
|
||||
// We load 'jasmine-core/jasmine.js' because we want to factor out
|
||||
// code paths that are common between browser and Node.js environments.
|
||||
// As a result, the `jasmineCore` object is missing some properties that
|
||||
// 'jasmine/jasmine.js' expects, so we manually populate what we need.
|
||||
|
||||
// 'jasmine/jasmine.js' calls `.boot()`
|
||||
jasmineCore.boot = evalInContext("$:/plugins/tiddlywiki/jasmine/jasmine-core/jasmine-core/node_boot.js");
|
||||
// 'jasmine/jasmine.js' references `.files.path`
|
||||
jasmineCore.files = {
|
||||
path: "$:/plugins/tiddlywiki/jasmine/jasmine-core/jasmine-core"
|
||||
};
|
||||
// 'jasmine/jasmine.js' references `process.exit`
|
||||
context.process = process;
|
||||
|
||||
var JasmineNode = evalInContext("$:/plugins/tiddlywiki/jasmine/jasmine/jasmine.js");
|
||||
var jasmineRunner = new JasmineNode({jasmineCore: jasmineCore});
|
||||
jasmineRunner.configureDefaultReporter({});
|
||||
jasmine = jasmineRunner.jasmine;
|
||||
}
|
||||
// Add Jasmine's DSL to our context
|
||||
var env = jasmine.getEnv();
|
||||
var jasmineInterface = jasmineCore.interface(jasmine,env)
|
||||
context = $tw.utils.extend({},jasmineInterface,context);
|
||||
// Iterate through all the test modules
|
||||
var tests = $tw.wiki.filterTiddlers(TEST_TIDDLER_FILTER);
|
||||
$tw.utils.each(tests,function(title) {
|
||||
evalInContext(title);
|
||||
});
|
||||
// Execute the tests
|
||||
jasmineEnv.execute();
|
||||
// In a browser environment, jasmine-core/boot.js calls `execute()` for us.
|
||||
// In Node.js, we call it manually.
|
||||
if(!$tw.browser) {
|
||||
env.execute();
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
@ -1,5 +1,5 @@
|
||||
title: $:/plugins/tiddlywiki/jasmine/readme
|
||||
|
||||
This plugin provides a framework for running tests in the browser and under Node.js. It is based on [[Jasmine|http://pivotal.github.io/jasmine/]] test framework.
|
||||
This plugin provides a framework for running tests in the browser and under Node.js. It is based on [[Jasmine|https://jasmine.github.io/]] test framework.
|
||||
|
||||
[[Source code|https://github.com/Jermolene/TiddlyWiki5/blob/master/plugins/tiddlywiki/jasmine]]
|
||||
|
30
plugins/tiddlywiki/jasmine/update-packages.sh
Executable file
30
plugins/tiddlywiki/jasmine/update-packages.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# Download jasmine packages from npm and unpack relevant files
|
||||
# into files/.
|
||||
|
||||
set -exuo pipefail
|
||||
|
||||
JASMINE_VERSION=3.4.0
|
||||
JASMINE_CORE_VERSION=3.4.0
|
||||
|
||||
rm -rf files/jasmine
|
||||
mkdir -p files/jasmine
|
||||
if [ ! -f "jasmine-$JASMINE_VERSION.tgz" ]; then
|
||||
npm pack jasmine@$JASMINE_VERSION
|
||||
fi
|
||||
tar xfzv jasmine-$JASMINE_VERSION.tgz \
|
||||
-C files/jasmine \
|
||||
--strip-components=1 \
|
||||
--wildcards "*/lib/*.js" "*/*.LICENSE" \
|
||||
--exclude "example"
|
||||
|
||||
rm -rf files/jasmine-core
|
||||
mkdir -p files/jasmine-core
|
||||
if [ ! -f "jasmine-core-$JASMINE_CORE_VERSION.tgz" ]; then
|
||||
npm pack jasmine-core@$JASMINE_CORE_VERSION
|
||||
fi
|
||||
tar xfzv jasmine-core-$JASMINE_CORE_VERSION.tgz \
|
||||
-C files/jasmine-core \
|
||||
--strip-components=1 \
|
||||
--wildcards "*/lib/*.js" "*/lib/*.css" "*/*.LICENSE" \
|
||||
--exclude "example"
|
Loading…
Reference in New Issue
Block a user