Make rake jasmine:ci run specs correctly.
- Will replace rake core_specs. - Remove obsolete dependencies & files -- most of these were for build tasks we are no longer using. Notably, rspec and spec_helper were deleted.
This commit is contained in:
494
spec/javascripts/html/HtmlReporterSpec.js
Normal file
494
spec/javascripts/html/HtmlReporterSpec.js
Normal file
@@ -0,0 +1,494 @@
|
||||
describe("New HtmlReporter", function() {
|
||||
// TODO: Figure out why this isn't rendering...
|
||||
it("builds the initial DOM elements, including the title banner", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
getContainer = function() { return container; },
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
// Main top-level elements
|
||||
expect(container.querySelector("div.html-reporter")).toBeTruthy();
|
||||
expect(container.querySelector("div.banner")).toBeTruthy();
|
||||
expect(container.querySelector("div.alert")).toBeTruthy();
|
||||
expect(container.querySelector("div.results")).toBeTruthy();
|
||||
|
||||
expect(container.querySelector("ul.symbol-summary")).toBeTruthy();
|
||||
|
||||
// title banner
|
||||
var banner = container.querySelector(".banner");
|
||||
|
||||
var title = banner.querySelector(".title");
|
||||
expect(title.innerHTML).toMatch(/Jasmine/);
|
||||
|
||||
var version = banner.querySelector(".version"),
|
||||
versionText = 'textContent' in version ? version.textContent : version.innerText;
|
||||
expect(versionText).toEqual(j$.version);
|
||||
});
|
||||
|
||||
it("starts the timer when jasmine begins", function() {
|
||||
var env = new jasmine.Env(),
|
||||
startTimerSpy = jasmine.createSpy("start-timer-spy"),
|
||||
reporter = new jasmine.HtmlReporter({
|
||||
env: env,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
timer: { start: startTimerSpy }
|
||||
});
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
|
||||
expect(startTimerSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe("when a spec is done", function() {
|
||||
it("reports the status symbol of a disabled spec", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
getContainer = function() { return container; },
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles"});
|
||||
|
||||
var specEl = container.querySelector('.symbol-summary li');
|
||||
expect(specEl.getAttribute("class")).toEqual("disabled");
|
||||
expect(specEl.getAttribute("id")).toEqual("spec_789");
|
||||
expect(specEl.getAttribute("title")).toEqual("symbols should have titles");
|
||||
});
|
||||
|
||||
it("reports the status symbol of a pending spec", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
getContainer = function() { return container; },
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({id: 789, status: "pending"});
|
||||
|
||||
var specEl = container.querySelector('.symbol-summary li');
|
||||
expect(specEl.getAttribute("class")).toEqual("pending");
|
||||
expect(specEl.getAttribute("id")).toEqual("spec_789");
|
||||
});
|
||||
|
||||
it("reports the status symbol of a passing spec", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
getContainer = function() { return container; },
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({id: 123, status: "passed"});
|
||||
|
||||
var statuses = container.querySelector(".symbol-summary");
|
||||
var specEl = statuses.querySelector("li");
|
||||
expect(specEl.getAttribute("class")).toEqual("passed");
|
||||
expect(specEl.getAttribute("id")).toEqual("spec_123");
|
||||
});
|
||||
|
||||
it("reports the status symbol of a failing spec", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
getContainer = function() { return container; },
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({
|
||||
id: 345,
|
||||
status: "failed",
|
||||
failedExpectations: []
|
||||
});
|
||||
|
||||
var specEl = container.querySelector(".symbol-summary li");
|
||||
expect(specEl.getAttribute("class")).toEqual("failed");
|
||||
expect(specEl.getAttribute("id")).toEqual("spec_345");
|
||||
});
|
||||
});
|
||||
|
||||
describe("when Jasmine is done", function() {
|
||||
it("reports the run time", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
timer = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
||||
getContainer = function() { return container; },
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
||||
timer: timer
|
||||
});
|
||||
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
|
||||
timer.elapsed.and.returnValue(100);
|
||||
reporter.jasmineDone();
|
||||
|
||||
var duration = container.querySelector(".banner .duration");
|
||||
expect(duration.innerHTML).toMatch(/finished in 0.1s/);
|
||||
});
|
||||
|
||||
it("reports the suite and spec names with status", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
getContainer = function() { return container; },
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.suiteStarted({
|
||||
id: 1,
|
||||
description: "A Suite",
|
||||
fullName: "A Suite"
|
||||
});
|
||||
|
||||
var specResult = {
|
||||
id: 123,
|
||||
description: "with a spec",
|
||||
fullName: "A Suite with a spec",
|
||||
status: "passed"
|
||||
};
|
||||
reporter.specStarted(specResult);
|
||||
reporter.specDone(specResult);
|
||||
|
||||
reporter.suiteStarted({
|
||||
id: 2,
|
||||
description: "inner suite",
|
||||
fullName: "A Suite inner suite"
|
||||
});
|
||||
|
||||
var specResult = {
|
||||
id: 124,
|
||||
description: "with another spec",
|
||||
fullName: "A Suite inner suite with another spec",
|
||||
status: "passed"
|
||||
};
|
||||
reporter.specStarted(specResult);
|
||||
reporter.specDone(specResult);
|
||||
|
||||
reporter.suiteDone({id: 2});
|
||||
|
||||
specResult = {
|
||||
id: 209,
|
||||
description: "with a failing spec",
|
||||
fullName: "A Suite inner with a failing spec",
|
||||
status: "failed",
|
||||
failedExpectations: []
|
||||
};
|
||||
reporter.specStarted(specResult);
|
||||
reporter.specDone(specResult);
|
||||
|
||||
reporter.suiteDone({id: 1});
|
||||
|
||||
reporter.jasmineDone({});
|
||||
var summary = container.querySelector(".summary");
|
||||
|
||||
expect(summary.childNodes.length).toEqual(1);
|
||||
|
||||
var outerSuite = summary.childNodes[0];
|
||||
expect(outerSuite.childNodes.length).toEqual(4);
|
||||
|
||||
var classes = [];
|
||||
for (var i = 0; i < outerSuite.childNodes.length; i++) {
|
||||
var node = outerSuite.childNodes[i];
|
||||
classes.push(node.getAttribute("class"));
|
||||
}
|
||||
expect(classes).toEqual(["suite-detail", "specs", "suite", "specs"]);
|
||||
|
||||
var suiteDetail = outerSuite.childNodes[0];
|
||||
var suiteLink = suiteDetail.childNodes[0];
|
||||
expect(suiteLink.innerHTML).toEqual("A Suite");
|
||||
expect(suiteLink.getAttribute('href')).toEqual("?spec=A%20Suite");
|
||||
|
||||
var specs = outerSuite.childNodes[1];
|
||||
var spec = specs.childNodes[0];
|
||||
expect(spec.getAttribute("class")).toEqual("passed");
|
||||
expect(spec.getAttribute("id")).toEqual("spec-123");
|
||||
|
||||
var specLink = spec.childNodes[0];
|
||||
expect(specLink.innerHTML).toEqual("with a spec");
|
||||
expect(specLink.getAttribute("href")).toEqual("?spec=A%20Suite%20with%20a%20spec");
|
||||
// expect(specLink.getAttribute("title")).toEqual("A Suite with a spec");
|
||||
});
|
||||
|
||||
describe("UI for raising/catching exceptions", function() {
|
||||
it("should be unchecked if the env is catching", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() {
|
||||
return document.createElement.apply(document, arguments);
|
||||
},
|
||||
createTextNode: function() {
|
||||
return document.createTextNode.apply(document, arguments);
|
||||
}
|
||||
});
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
var raisingExceptionsUI = container.querySelector(".raise");
|
||||
expect(raisingExceptionsUI.checked).toBe(false);
|
||||
});
|
||||
|
||||
it("should be checked if the env is not catching", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() {
|
||||
return document.createElement.apply(document, arguments);
|
||||
},
|
||||
createTextNode: function() {
|
||||
return document.createTextNode.apply(document, arguments);
|
||||
}
|
||||
});
|
||||
|
||||
reporter.initialize();
|
||||
env.catchExceptions(false);
|
||||
reporter.jasmineDone({});
|
||||
|
||||
var raisingExceptionsUI = container.querySelector(".raise");
|
||||
expect(raisingExceptionsUI.checked).toBe(true);
|
||||
});
|
||||
|
||||
it("should affect the query param for catching exceptions", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
exceptionsClickHandler = jasmine.createSpy("raise exceptions checked"),
|
||||
getContainer = function() {
|
||||
return container;
|
||||
},
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
onRaiseExceptionsClick: exceptionsClickHandler,
|
||||
createElement: function() {
|
||||
return document.createElement.apply(document, arguments);
|
||||
},
|
||||
createTextNode: function() {
|
||||
return document.createTextNode.apply(document, arguments);
|
||||
}
|
||||
});
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineDone({});
|
||||
|
||||
var input = container.querySelector(".raise");
|
||||
input.click();
|
||||
expect(exceptionsClickHandler).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("and all specs pass", function() {
|
||||
var env, container, reporter;
|
||||
beforeEach(function() {
|
||||
env = new j$.Env();
|
||||
container = document.createElement("div");
|
||||
getContainer = function() { return container; },
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.specDone({
|
||||
id: 123,
|
||||
description: "with a spec",
|
||||
fullName: "A Suite with a spec",
|
||||
status: "passed"
|
||||
});
|
||||
reporter.specDone({
|
||||
id: 124,
|
||||
description: "with another spec",
|
||||
fullName: "A Suite inner suite with another spec",
|
||||
status: "passed"
|
||||
});
|
||||
reporter.jasmineDone({});
|
||||
});
|
||||
|
||||
it("reports the specs counts", function() {
|
||||
var alertBars = container.querySelectorAll(".alert .bar");
|
||||
|
||||
expect(alertBars.length).toEqual(1);
|
||||
expect(alertBars[0].getAttribute('class')).toMatch(/passed/);
|
||||
expect(alertBars[0].innerHTML).toMatch(/2 specs, 0 failures/);
|
||||
});
|
||||
|
||||
it("reports no failure details", function() {
|
||||
var specFailure = container.querySelector(".failures");
|
||||
|
||||
expect(specFailure.childNodes.length).toEqual(0);
|
||||
});
|
||||
|
||||
it("reports no pending specs", function() {
|
||||
var alertBar = container.querySelector(".alert .bar");
|
||||
|
||||
expect(alertBar.innerHTML).not.toMatch(/pending spec[s]/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("and there are pending specs", function() {
|
||||
var env, container, reporter;
|
||||
beforeEach(function() {
|
||||
env = new j$.Env();
|
||||
container = document.createElement("div");
|
||||
getContainer = function() { return container; },
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
reporter.specDone({
|
||||
id: 123,
|
||||
description: "with a spec",
|
||||
fullName: "A Suite with a spec",
|
||||
status: "pending"
|
||||
});
|
||||
reporter.jasmineDone({});
|
||||
});
|
||||
|
||||
it("reports the pending specs count", function() {
|
||||
var alertBar = container.querySelector(".alert .bar");
|
||||
|
||||
expect(alertBar.innerHTML).toMatch(/1 spec, 0 failures, 1 pending spec/);
|
||||
});
|
||||
|
||||
it("reports no failure details", function() {
|
||||
var specFailure = container.querySelector(".failures");
|
||||
|
||||
expect(specFailure.childNodes.length).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("and some tests fail", function() {
|
||||
var env, container, reporter;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new j$.Env();
|
||||
container = document.createElement("div"),
|
||||
getContainer = function() { return container; },
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.jasmineStarted({});
|
||||
|
||||
var passingResult = {id: 123, status: "passed"};
|
||||
reporter.specStarted(passingResult);
|
||||
reporter.specDone(passingResult);
|
||||
|
||||
var failingResult = {
|
||||
id: 124,
|
||||
status: "failed",
|
||||
description: "a failing spec",
|
||||
fullName: "a suite with a failing spec",
|
||||
failedExpectations: [
|
||||
{
|
||||
message: "a failure message",
|
||||
stack: "a stack trace"
|
||||
}
|
||||
]
|
||||
};
|
||||
reporter.specStarted(failingResult);
|
||||
reporter.specDone(failingResult);
|
||||
reporter.jasmineDone({});
|
||||
});
|
||||
|
||||
it("reports the specs counts", function() {
|
||||
var alertBar = container.querySelector(".alert .bar");
|
||||
|
||||
expect(alertBar.getAttribute('class')).toMatch(/failed/);
|
||||
expect(alertBar.innerHTML).toMatch(/2 specs, 1 failure/);
|
||||
});
|
||||
|
||||
it("reports failure messages and stack traces", function() {
|
||||
var specFailures = container.querySelector(".failures");
|
||||
|
||||
var failure = specFailures.childNodes[0];
|
||||
expect(failure.getAttribute("class")).toMatch(/failed/);
|
||||
expect(failure.getAttribute("class")).toMatch(/spec-detail/);
|
||||
|
||||
var specLink = failure.childNodes[0];
|
||||
expect(specLink.getAttribute("class")).toEqual("description");
|
||||
expect(specLink.getAttribute("title")).toEqual("a suite with a failing spec");
|
||||
expect(specLink.getAttribute("href")).toEqual("?spec=a%20suite%20with%20a%20failing%20spec");
|
||||
|
||||
var message = failure.childNodes[1].childNodes[0];
|
||||
expect(message.getAttribute("class")).toEqual("result-message");
|
||||
expect(message.innerHTML).toEqual("a failure message");
|
||||
|
||||
var stackTrace = failure.childNodes[1].childNodes[1];
|
||||
expect(stackTrace.getAttribute("class")).toEqual("stack-trace");
|
||||
expect(stackTrace.innerHTML).toEqual("a stack trace");
|
||||
});
|
||||
|
||||
it("allows switching between failure details and the spec summary", function() {
|
||||
var menuBar = container.querySelectorAll(".bar")[1];
|
||||
|
||||
expect(menuBar.getAttribute("class")).not.toMatch(/hidden/);
|
||||
|
||||
var link = menuBar.querySelector('a');
|
||||
expect(link.innerHTML).toEqual("Failures");
|
||||
expect(link.getAttribute("href")).toEqual("#");
|
||||
});
|
||||
|
||||
it("sets the reporter to 'Failures List' mode", function() {
|
||||
var reporterNode = container.querySelector(".html-reporter");
|
||||
expect(reporterNode.getAttribute("class")).toMatch("failure-list");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
18
spec/javascripts/html/HtmlSpecFilterSpec.js
Normal file
18
spec/javascripts/html/HtmlSpecFilterSpec.js
Normal file
@@ -0,0 +1,18 @@
|
||||
describe("j$.HtmlSpecFilter", function() {
|
||||
|
||||
it("should match when no string is provided", function() {
|
||||
var specFilter = new j$.HtmlSpecFilter();
|
||||
|
||||
expect(specFilter.matches("foo")).toBe(true);
|
||||
expect(specFilter.matches("*bar")).toBe(true);
|
||||
});
|
||||
|
||||
it("should only match the provided string", function() {
|
||||
var specFilter = new j$.HtmlSpecFilter({
|
||||
filterString: function() { return "foo"; }
|
||||
});
|
||||
|
||||
expect(specFilter.matches("foo")).toBe(true);
|
||||
expect(specFilter.matches("bar")).toBe(false);
|
||||
});
|
||||
});
|
||||
38
spec/javascripts/html/MatchersHtmlSpec.js
Normal file
38
spec/javascripts/html/MatchersHtmlSpec.js
Normal file
@@ -0,0 +1,38 @@
|
||||
describe("MatchersSpec - HTML Dependent", function () {
|
||||
var env, spec;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new j$.Env();
|
||||
env.updateInterval = 0;
|
||||
|
||||
var suite = env.describe("suite", function() {
|
||||
spec = env.it("spec", function() {
|
||||
});
|
||||
});
|
||||
spyOn(spec, 'addExpectationResult');
|
||||
|
||||
addMatchers({
|
||||
toPass: function() {
|
||||
return lastResult().passed;
|
||||
},
|
||||
toFail: function() {
|
||||
return !lastResult().passed;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function match(value) {
|
||||
return spec.expect(value);
|
||||
}
|
||||
|
||||
function lastResult() {
|
||||
return spec.addExpectationResult.mostRecentCall.args[1];
|
||||
}
|
||||
|
||||
xit("toEqual with DOM nodes", function() {
|
||||
var nodeA = document.createElement('div');
|
||||
var nodeB = document.createElement('div');
|
||||
expect((match(nodeA).toEqual(nodeA))).toPass();
|
||||
expect((match(nodeA).toEqual(nodeB))).toFail();
|
||||
});
|
||||
});
|
||||
15
spec/javascripts/html/PrettyPrintHtmlSpec.js
Normal file
15
spec/javascripts/html/PrettyPrintHtmlSpec.js
Normal file
@@ -0,0 +1,15 @@
|
||||
describe("j$.pp (HTML Dependent)", function () {
|
||||
it("should stringify HTML nodes properly", function() {
|
||||
var sampleNode = document.createElement('div');
|
||||
sampleNode.innerHTML = 'foo<b>bar</b>';
|
||||
expect(j$.pp(sampleNode)).toEqual("HTMLNode");
|
||||
expect(j$.pp({foo: sampleNode})).toEqual("{ foo : HTMLNode }");
|
||||
});
|
||||
|
||||
it("should print Firefox's wrapped native objects correctly", function() {
|
||||
if(jasmine.getEnv().firefoxVersion) {
|
||||
try { new CustomEvent(); } catch(e) { var err = e; };
|
||||
expect(j$.pp(err)).toMatch(/Exception.*Not enough arguments/);
|
||||
}
|
||||
});
|
||||
});
|
||||
43
spec/javascripts/html/QueryStringSpec.js
Normal file
43
spec/javascripts/html/QueryStringSpec.js
Normal file
@@ -0,0 +1,43 @@
|
||||
describe("QueryString", function() {
|
||||
|
||||
describe("#setParam", function() {
|
||||
|
||||
it("sets the query string to include the given key/value pair", function() {
|
||||
var windowLocation = {
|
||||
search: ""
|
||||
},
|
||||
queryString = new j$.QueryString({
|
||||
getWindowLocation: function() { return windowLocation }
|
||||
});
|
||||
|
||||
queryString.setParam("foo", "bar baz");
|
||||
|
||||
expect(windowLocation.search).toMatch(/foo=bar%20baz/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#getParam", function() {
|
||||
|
||||
it("returns the value of the requested key", function() {
|
||||
var windowLocation = {
|
||||
search: "?baz=quux%20corge"
|
||||
},
|
||||
queryString = new j$.QueryString({
|
||||
getWindowLocation: function() { return windowLocation }
|
||||
});
|
||||
|
||||
expect(queryString.getParam("baz")).toEqual("quux corge");
|
||||
});
|
||||
|
||||
it("returns null if the key is not present", function() {
|
||||
var windowLocation = {
|
||||
search: ""
|
||||
},
|
||||
queryString = new j$.QueryString({
|
||||
getWindowLocation: function() { return windowLocation }
|
||||
});
|
||||
|
||||
expect(queryString.getParam("baz")).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
62
spec/javascripts/html/ResultsNodeSpec.js
Normal file
62
spec/javascripts/html/ResultsNodeSpec.js
Normal file
@@ -0,0 +1,62 @@
|
||||
describe("ResultsNode", function() {
|
||||
it("wraps a result", function() {
|
||||
var fakeResult = {
|
||||
id: 123,
|
||||
message: "foo"
|
||||
},
|
||||
node = new j$.ResultsNode(fakeResult, "suite", null);
|
||||
|
||||
expect(node.result).toBe(fakeResult);
|
||||
expect(node.type).toEqual("suite");
|
||||
});
|
||||
|
||||
it("can add children with a type", function() {
|
||||
var fakeResult = {
|
||||
id: 123,
|
||||
message: "foo"
|
||||
},
|
||||
fakeChildResult = {
|
||||
id: 456,
|
||||
message: "bar"
|
||||
},
|
||||
node = new j$.ResultsNode(fakeResult, "suite", null);
|
||||
|
||||
node.addChild(fakeChildResult, "spec");
|
||||
|
||||
expect(node.children.length).toEqual(1);
|
||||
expect(node.children[0].result).toEqual(fakeChildResult);
|
||||
expect(node.children[0].type).toEqual("spec");
|
||||
});
|
||||
|
||||
it("has a pointer back to its parent ResultNode", function() {
|
||||
var fakeResult = {
|
||||
id: 123,
|
||||
message: "foo"
|
||||
},
|
||||
fakeChildResult = {
|
||||
id: 456,
|
||||
message: "bar"
|
||||
},
|
||||
node = new j$.ResultsNode(fakeResult, "suite", null);
|
||||
|
||||
node.addChild(fakeChildResult, "spec");
|
||||
|
||||
expect(node.children[0].parent).toBe(node);
|
||||
});
|
||||
|
||||
it("can provide the most recent child", function() {
|
||||
var fakeResult = {
|
||||
id: 123,
|
||||
message: "foo"
|
||||
},
|
||||
fakeChildResult = {
|
||||
id: 456,
|
||||
message: "bar"
|
||||
},
|
||||
node = new j$.ResultsNode(fakeResult, "suite", null);
|
||||
|
||||
node.addChild(fakeChildResult, "spec");
|
||||
|
||||
expect(node.last()).toBe(node.children[node.children.length - 1]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user