Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

exchanges jasmine for mocha and expect.js

commit 3dcbf4e14331e1f7a4f1decc47b2058d01bd4d02 1 parent 06d561e
@MathiasPaumgarten authored
View
5 karma.config.js
@@ -4,11 +4,12 @@
basePath = ".";
files = [
- JASMINE,
- JASMINE_ADAPTER,
+ MOCHA,
+ MOCHA_ADAPTER,
REQUIRE,
REQUIRE_ADAPTER,
"node_modules/sinon/pkg/sinon.js",
+ "node_modules/expect.js/expect.js",
"tests/runner.js",
{ pattern: "source/**/*.js", included: false },
{ pattern: "tests/**/*.js", included: false },
View
3  package.json
@@ -49,6 +49,7 @@
"express": "~3.4.0",
"mout": "~0.5.0",
"mdoc": "~0.3.4",
- "sinon": "~1.7.3"
+ "sinon": "~1.7.3",
+ "expect.js": "~0.2.0"
}
}
View
16 tests/dom/spec-append.js
@@ -9,10 +9,10 @@ define(["cane/dom/append"], function(append) {
parent.appendChild(first);
append(parent, last);
-
- expect(parent.childNodes.length).toBe(2);
- expect(parent.firstChild).toBe(first);
- expect(parent.lastChild).toBe(last);
+
+ expect(parent.childNodes.length).to.be(2);
+ expect(parent.firstChild).to.be(first);
+ expect(parent.lastChild).to.be(last);
});
it("should append multiple nodes", function() {
@@ -23,10 +23,10 @@ define(["cane/dom/append"], function(append) {
append(parent, one, [two, three]);
- expect(parent.childNodes.length).toBe(3);
- expect(parent.childNodes[0]).toBe(one);
- expect(parent.childNodes[1]).toBe(two);
- expect(parent.childNodes[2]).toBe(three);
+ expect(parent.childNodes.length).to.be(3);
+ expect(parent.childNodes[0]).to.be(one);
+ expect(parent.childNodes[1]).to.be(two);
+ expect(parent.childNodes[2]).to.be(three);
});
});
View
10 tests/dom/spec-children.js
@@ -8,10 +8,10 @@ define(["cane/dom/children"], function(children) {
var nodes = children(parent);
- expect(nodes.length).toBe(3);
- expect(nodes[0].nodeType).toBe(1);
- expect(nodes[1].nodeType).toBe(1);
- expect(nodes[2].nodeType).toBe(1);
+ expect(nodes.length).to.be(3);
+ expect(nodes[0].nodeType).to.be(1);
+ expect(nodes[1].nodeType).to.be(1);
+ expect(nodes[2].nodeType).to.be(1);
});
it("should return the children of several nodes", function() {
@@ -23,7 +23,7 @@ define(["cane/dom/children"], function(children) {
var nodes = children( [parentOne, parentTwo] );
- expect(nodes.length).toBe(5);
+ expect(nodes.length).to.be(5);
});
});
View
36 tests/dom/spec-create.js
@@ -5,15 +5,15 @@ define(["cane/dom/create"], function(create) {
it("should create element with tag name", function() {
var el = create("div");
- expect(el.nodeType).toBe(Node.ELEMENT_NODE);
- expect(el.tagName).toBe("DIV");
+ expect(el.nodeType).to.be(Node.ELEMENT_NODE);
+ expect(el.tagName).to.be("DIV");
});
it("should set attributes on element", function() {
var el = create("div", { "class": "test", "data-test": "value" });
- expect(el.className).toBe("test");
- expect(el.getAttribute("data-test")).toBe("value");
+ expect(el.className).to.be("test");
+ expect(el.getAttribute("data-test")).to.be("value");
});
it("should add child nodes", function() {
@@ -22,9 +22,9 @@ define(["cane/dom/create"], function(create) {
el = create("div", one, two);
var nodes = el.childNodes;
- expect(nodes.length).toBe(2);
- expect(nodes[0]).toBe(one);
- expect(nodes[1]).toBe(two);
+ expect(nodes.length).to.be(2);
+ expect(nodes[0]).to.be(one);
+ expect(nodes[1]).to.be(two);
});
it("should add array of child nodes", function() {
@@ -34,10 +34,10 @@ define(["cane/dom/create"], function(create) {
el = create("div", [one, two], three);
var nodes = el.childNodes;
- expect(nodes.length).toBe(3);
- expect(nodes[0]).toBe(one);
- expect(nodes[1]).toBe(two);
- expect(nodes[2]).toBe(three);
+ expect(nodes.length).to.be(3);
+ expect(nodes[0]).to.be(one);
+ expect(nodes[1]).to.be(two);
+ expect(nodes[2]).to.be(three);
});
it("should set attributes and add child nodes", function() {
@@ -45,27 +45,27 @@ define(["cane/dom/create"], function(create) {
two = document.createElement("span"),
el = create("div", { "class": "test" }, one, two);
- expect(el.className).toBe("test");
+ expect(el.className).to.be("test");
var nodes = el.childNodes;
- expect(nodes.length).toBe(2);
- expect(nodes[0]).toBe(one);
- expect(nodes[1]).toBe(two);
+ expect(nodes.length).to.be(2);
+ expect(nodes[0]).to.be(one);
+ expect(nodes[1]).to.be(two);
});
it("should set text", function() {
var text = "test <span>test</span>",
el = create("div", text);
- expect(el.textContent).toBe(text);
+ expect(el.textContent).to.be(text);
});
it("should set attributes and text", function() {
var text = "test content",
el = create("div", { "class": "test" }, text);
- expect(el.className).toBe("test");
- expect(el.textContent).toBe(text);
+ expect(el.className).to.be("test");
+ expect(el.textContent).to.be(text);
});
});
View
6 tests/dom/spec-empty.js
@@ -13,7 +13,7 @@ define(["cane/dom/empty"], function(empty) {
empty(parent);
- expect(parent.childNodes.length).toBe(0);
+ expect(parent.childNodes.length).to.be(0);
});
@@ -33,8 +33,8 @@ define(["cane/dom/empty"], function(empty) {
empty(parentOne, parentTwo);
- expect(parentOne.childNodes.length).toBe(0);
- expect(parentTwo.childNodes.length).toBe(0);
+ expect(parentOne.childNodes.length).to.be(0);
+ expect(parentTwo.childNodes.length).to.be(0);
});
});
});
View
18 tests/dom/spec-fragment.js
@@ -4,8 +4,8 @@ define(["cane/dom/fragment"], function(fragment) {
it("should create empty DocumentFragment", function() {
var f = fragment();
- expect(f.nodeType).toBe(Node.DOCUMENT_FRAGMENT_NODE);
- expect(f.childNodes.length).toBe(0);
+ expect(f.nodeType).to.be(Node.DOCUMENT_FRAGMENT_NODE);
+ expect(f.childNodes.length).to.be(0);
});
it("should add nodes", function() {
@@ -13,9 +13,9 @@ define(["cane/dom/fragment"], function(fragment) {
second = document.createTextNode("Test"),
f = fragment(first, second);
- expect(f.childNodes.length).toBe(2);
- expect(f.firstChild).toBe(first);
- expect(f.lastChild).toBe(second);
+ expect(f.childNodes.length).to.be(2);
+ expect(f.firstChild).to.be(first);
+ expect(f.lastChild).to.be(second);
});
it("should add nested arrays", function() {
@@ -24,10 +24,10 @@ define(["cane/dom/fragment"], function(fragment) {
three = document.createElement("div"),
f = fragment(one, [two, [three]]);
- expect(f.childNodes.length).toBe(3);
- expect(f.childNodes[0]).toBe(one);
- expect(f.childNodes[1]).toBe(two);
- expect(f.childNodes[2]).toBe(three);
+ expect(f.childNodes.length).to.be(3);
+ expect(f.childNodes[0]).to.be(one);
+ expect(f.childNodes[1]).to.be(two);
+ expect(f.childNodes[2]).to.be(three);
});
});
View
8 tests/dom/spec-matches.js
@@ -6,20 +6,20 @@ define(["cane/dom/matches"], function(matches) {
var node = document.createElement("div");
node.className = "test";
- expect( matches("div.test", node) ).toBe(true);
+ expect( matches("div.test", node) ).to.be(true);
});
it("should return false if node does not match selector", function() {
var node = document.createElement("div");
- expect( matches(".bar", node) ).toBe(false);
+ expect( matches(".bar", node) ).to.be(false);
});
it("should return true if all nodes match", function() {
var first = document.createElement("div"),
second = document.createElement("div");
- expect( matches("div", first, second) ).toBe(true);
+ expect( matches("div", first, second) ).to.be(true);
});
it("should return false if any of the nodes do not match", function() {
@@ -27,7 +27,7 @@ define(["cane/dom/matches"], function(matches) {
second = document.createElement("div");
first.className = "foo";
- expect( matches(".foo", first, second) ).toBe(false);
+ expect( matches(".foo", first, second) ).to.be(false);
});
});
View
12 tests/dom/spec-prepend.js
@@ -10,9 +10,9 @@ define(["cane/dom/prepend"], function(prepend) {
parent.appendChild(last);
prepend(parent, first);
- expect(parent.childNodes.length).toBe(2);
- expect(parent.firstChild).toBe(first);
- expect(parent.lastChild).toBe(last);
+ expect(parent.childNodes.length).to.be(2);
+ expect(parent.firstChild).to.be(first);
+ expect(parent.lastChild).to.be(last);
});
it("should add multiple nodes", function() {
@@ -24,9 +24,9 @@ define(["cane/dom/prepend"], function(prepend) {
prepend(parent, one, [two, three]);
var nodes = parent.childNodes;
- expect(nodes[0]).toBe(one);
- expect(nodes[1]).toBe(two);
- expect(nodes[2]).toBe(three);
+ expect(nodes[0]).to.be(one);
+ expect(nodes[1]).to.be(two);
+ expect(nodes[2]).to.be(three);
});
});
View
8 tests/dom/spec-remove.js
@@ -12,8 +12,8 @@ define(["cane/dom/remove"], function(remove) {
remove(childOne);
- expect(parent.children.length).toBe(1);
- expect(parent.firstChild).toBe(childTwo);
+ expect(parent.children.length).to.be(1);
+ expect(parent.firstChild).to.be(childTwo);
});
it("should remove multiple nodes", function() {
@@ -29,7 +29,7 @@ define(["cane/dom/remove"], function(remove) {
remove(children[0], [children[1], children[2]]);
- expect(parent.children.length).toBe(0);
+ expect(parent.children.length).to.be(0);
});
it("should remove text nodes", function() {
@@ -39,7 +39,7 @@ define(["cane/dom/remove"], function(remove) {
remove(text);
- expect(parent.children.length).toBe(0);
+ expect(parent.children.length).to.be(0);
});
it("should ignore nodes that do not have a parent", function() {
View
6 tests/dom/spec-setText.js
@@ -7,7 +7,7 @@ define(["cane/dom/setText"], function(setText) {
setText(el, "foo bar");
- expect(el.textContent).toBe("foo bar");
+ expect(el.textContent).to.be("foo bar");
});
it("shold set text content of multiple nodes", function() {
@@ -16,8 +16,8 @@ define(["cane/dom/setText"], function(setText) {
setText([first, second], "foo");
- expect(first.textContent).toBe("foo");
- expect(second.textContent).toBe("foo");
+ expect(first.textContent).to.be("foo");
+ expect(second.textContent).to.be("foo");
});
});
});
View
10 tests/events/spec-delegate.js
@@ -19,7 +19,7 @@ define(["cane/events/delegate"], function(delegate) {
child.dispatchEvent(event);
document.body.removeChild(main);
- expect(handler.calledOn(child)).toBe(true);
+ expect(handler.calledOn(child)).to.be(true);
});
it("should ignore events on elements that do not match", function() {
@@ -36,7 +36,7 @@ define(["cane/events/delegate"], function(delegate) {
child.dispatchEvent(event);
document.body.removeChild(main);
- expect(handler.called).toBe(false);
+ expect(handler.called).to.be(false);
});
it("should ignore events on main element", function() {
@@ -51,7 +51,7 @@ define(["cane/events/delegate"], function(delegate) {
main.dispatchEvent(event);
document.body.removeChild(main);
- expect(handler.called).toBe(false);
+ expect(handler.called).to.be(false);
});
it("should return an object with .remove function", function() {
@@ -69,7 +69,7 @@ define(["cane/events/delegate"], function(delegate) {
listener.remove();
child.dispatchEvent(event);
- expect(handler.calledOnce).toBe(true);
+ expect(handler.calledOnce).to.be(true);
});
it("should accept multiple elements", function() {
@@ -91,7 +91,7 @@ define(["cane/events/delegate"], function(delegate) {
child1.dispatchEvent(event);
child2.dispatchEvent(event);
- expect(handler.calledTwice).toBe(true);
+ expect(handler.calledTwice).to.be(true);
});
});
View
20 tests/events/spec-listen.js
@@ -11,9 +11,9 @@ define(["cane/events/listen"], function(listen) {
listen(el, "test", callback);
el.dispatchEvent(event);
- expect(callback.calledOnce).toBe(true);
- expect(callback.calledWith(event)).toBe(true);
- expect(callback.calledOn(el)).toBe(true);
+ expect(callback.calledOnce).to.be(true);
+ expect(callback.calledWith(event)).to.be(true);
+ expect(callback.calledOn(el)).to.be(true);
});
it("should listen on multiple nodes", function() {
@@ -26,12 +26,12 @@ define(["cane/events/listen"], function(listen) {
listen([first, second], "test", callback);
first.dispatchEvent(event);
- expect(callback.calledOnce).toBe(true);
- expect(callback.calledOn(first)).toBe(true);
+ expect(callback.calledOnce).to.be(true);
+ expect(callback.calledOn(first)).to.be(true);
second.dispatchEvent(event);
- expect(callback.calledTwice).toBe(true);
- expect(callback.calledOn(first)).toBe(true);
+ expect(callback.calledTwice).to.be(true);
+ expect(callback.calledOn(first)).to.be(true);
});
it("should listen on multiple nodes", function() {
@@ -45,10 +45,10 @@ define(["cane/events/listen"], function(listen) {
listen(el, "foo bar", callback);
el.dispatchEvent(fooEvent);
- expect(callback.calledWith(fooEvent)).toBe(true);
+ expect(callback.calledWith(fooEvent)).to.be(true);
el.dispatchEvent(barEvent);
- expect(callback.calledWith(barEvent)).toBe(true);
+ expect(callback.calledWith(barEvent)).to.be(true);
});
it("should return a remove function to remove listener", function() {
@@ -61,7 +61,7 @@ define(["cane/events/listen"], function(listen) {
listener.remove();
el.dispatchEvent(event);
- expect(callback.called).toBe(false);
+ expect(callback.called).to.be(false);
});
});
View
6 tests/events/spec-removeListener.js
@@ -12,7 +12,7 @@ define(["cane/events/removeListener"], function(removeListener) {
removeListener(el, "test", callback);
el.dispatchEvent(event);
- expect(callback.called).toBe(false);
+ expect(callback.called).to.be(false);
});
it("should remove event listener from multiple nodes", function() {
@@ -28,7 +28,7 @@ define(["cane/events/removeListener"], function(removeListener) {
first.dispatchEvent(event);
second.dispatchEvent(event);
- expect(callback.called).toBe(false);
+ expect(callback.called).to.be(false);
});
it("should ignore if listener has not been added", function() {
@@ -54,7 +54,7 @@ define(["cane/events/removeListener"], function(removeListener) {
el.dispatchEvent(fooEvent);
el.dispatchEvent(barEvent);
- expect(callback.called).toBe(false);
+ expect(callback.called).to.be(false);
});
});
View
57 tests/net/spec-getJSON.js
@@ -2,59 +2,28 @@ define(["cane/net/getJSON"], function(getJSON) {
describe("net/getJSON", function() {
- it("should call success callback with JSON", function() {
- var completed = false,
- jsonContent = null;
-
+ it("should call success callback with JSON", function(done) {
getJSON("base/tests/resources/test.json", function(data) {
- completed = true;
- jsonContent = data;
- });
-
- waitsFor(function() {
- return completed;
- }, "Request never completed", 10000);
-
- runs(function() {
- expect(jsonContent).toEqual({ "foo": "bar", "test": [1, 2, 3], "boolean": false });
+ expect(data).to.eql({ "foo": "bar", "test": [1, 2, 3], "boolean": false });
+ done();
});
});
- it("should call error callback when resource can't be loaded", function() {
- var completed = false,
- success = sinon.spy();
-
- function error() {
- completed = true;
- }
+ it("should call error callback when resource can't be loaded", function(done) {
+ var success = sinon.spy();
- getJSON("base/tests/resources/wrong.json", success, error);
-
- waitsFor(function() {
- return completed;
- }, "Request never completed", 10000);
-
- runs(function() {
- expect(success.called).toBe(false);
+ getJSON("base/tests/resources/wrong.json", success, function() {
+ expect(success.called).to.be(false);
+ done();
});
});
- it("should call error callback when resource is not valid JSON", function() {
- var completed = false,
- success = sinon.spy();
-
- function error() {
- completed = true;
- }
-
- getJSON("base/tests/resources/invalid.json", success, error);
-
- waitsFor(function() {
- return completed;
- }, "Request never completed", 10000);
+ it("should call error callback when resource is not valid JSON", function(done) {
+ var success = sinon.spy();
- runs(function() {
- expect(success.called).toBe(false);
+ getJSON("base/tests/resources/invalid.json", success, function() {
+ expect(success.called).to.be(false);
+ done();
});
});
});
View
61 tests/net/spec-jsonp.js
@@ -6,73 +6,52 @@ define(["cane/net/jsonp"], function(jsonp) {
var mirrorURL = url + "mirror";
var staticURL = url + "static";
- it("should call resource using jsonp", function() {
- var completed = false;
- var content = null;
-
+ it("should call resource using jsonp", function(done) {
jsonp(staticURL, function(data) {
- completed = true;
- content = data;
- });
-
- waitsFor(function() {
- return completed;
- }, "Request never completed", 10000);
-
- runs(function() {
- expect(content).toEqual({ "foo": "bar" });
+ expect(data).to.eql({ "foo": "bar" });
+ done();
});
});
- it("should send data", function() {
- var completed = false;
- var content = null;
+ it("should send data", function(done) {
var parameters = {
foo: "complex string & characters like %^*",
bar: "another value"
};
- function onComplete(data) {
- completed = true;
- content = data;
- }
-
- jsonp(mirrorURL, parameters, onComplete);
-
- waitsFor(function() {
- return completed;
- }, "Request never completed", 10000);
-
- runs(function() {
- expect(content).toEqual(parameters);
@conradz Collaborator
conradz added a note

:heart: all this code removal :+1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ jsonp(mirrorURL, parameters, function(data) {
+ expect(data).to.eql(parameters);
+ done();
});
});
- it("should manage multiple requests parallel", function() {
+ it("should manage multiple requests parallel", function( done ) {
var complete = [false, false, false];
var content = [];
+ function validate() {
+ if (complete[0] && complete[1] && complete[2]) {
+
+ expect(content[0]).to.eql({ value: "one" });
+ expect(content[1]).to.eql({ value: "two" });
+ expect(content[2]).to.eql({ value: "three" });
+
+ done();
+ }
+ }
+
function onComplete(index) {
return function(data) {
complete[index] = true;
content[index] = data;
+ validate();
};
}
jsonp(mirrorURL, { value: "one" }, onComplete(0) );
jsonp(mirrorURL, { value: "two" }, onComplete(1) );
jsonp(mirrorURL, { value: "three" }, onComplete(2) );
-
- waitsFor(function() {
- return complete[0] && complete[1] && complete[2];
- }, "Request never completed", 10000 );
-
- runs(function() {
- expect(content[0]).toEqual({ value: "one" });
- expect(content[1]).toEqual({ value: "two" });
- expect(content[2]).toEqual({ value: "three" });
- });
});
});
View
66 tests/net/spec-request.js
@@ -2,60 +2,28 @@ define(["cane/net/request"], function(request) {
describe("net/request()", function() {
- it("should trigger completed and success", function() {
-
- var completed = false;
- var success = false;
- var response = {};
-
+ it("should trigger completed and success", function(done) {
request({
url: "base/tests/resources/test.txt",
completed: function(responseDate, status) {
- response.text = responseDate;
- response.status = status;
- completed = true;
+ expect(responseDate).to.be("Successfully loaded");
+ expect(status).to.be(200);
},
success: function() {
- success = true;
+ done();
}
});
-
- waitsFor(function() {
- return completed && success;
- }, "Request never completed", 10000);
-
- runs(function() {
- expect(response.text).toBe("Successfully loaded");
- expect(response.status).toBe(200);
- });
-
});
- it("should trigger completed and error", function() {
-
- var completed = false;
- var error = false;
- var response = {};
+ it("should trigger error", function(done) {
request({
url: "base/tests/resources/wrong.txt",
- completed: function() {
- completed = true;
- },
error: function(responseData, status) {
- response.status = status;
- error = true;
+ expect(status).to.be(404);
+ done();
}
});
-
- waitsFor(function() {
- return completed && error;
- }, "Request never completed", 10000);
-
- runs(function() {
- expect(response.status).toBe(404);
- });
-
});
describe("request methods and parameters", function() {
@@ -76,8 +44,8 @@ define(["cane/net/request"], function(request) {
});
var xhr = server.requests[0];
- expect(xhr.method).toEqual("POST");
- expect(xhr.url).toEqual("/test");
+ expect(xhr.method).to.equal("POST");
+ expect(xhr.url).to.equal("/test");
});
it("should use PUT method", function() {
@@ -87,8 +55,8 @@ define(["cane/net/request"], function(request) {
});
var xhr = server.requests[0];
- expect(xhr.method).toEqual("PUT");
- expect(xhr.url).toEqual("/test");
+ expect(xhr.method).to.equal("PUT");
+ expect(xhr.url).to.equal("/test");
});
it("should add header parameters", function() {
@@ -102,7 +70,7 @@ define(["cane/net/request"], function(request) {
});
var xhr = server.requests[0];
- expect(xhr.requestHeaders).toEqual(headers);
+ expect(xhr.requestHeaders).to.eql(headers);
});
it("should send data", function() {
@@ -115,7 +83,7 @@ define(["cane/net/request"], function(request) {
});
var xhr = server.requests[0];
- expect(xhr.requestBody).toEqual(data);
+ expect(xhr.requestBody).to.equal(data);
});
});
@@ -141,7 +109,7 @@ define(["cane/net/request"], function(request) {
var xhr = server.requests[0];
xhr.respond(200, {}, "");
- expect(success.calledWith("", 200)).toBe(true);
+ expect(success.calledWith("", 200)).to.be(true);
});
it("should call success on 304 response", function() {
@@ -154,7 +122,7 @@ define(["cane/net/request"], function(request) {
var xhr = server.requests[0];
xhr.respond(304, {}, "");
- expect(success.calledWith("", 304)).toBe(true);
+ expect(success.calledWith("", 304)).to.be(true);
});
it("should call error on 400 response", function() {
@@ -167,7 +135,7 @@ define(["cane/net/request"], function(request) {
var xhr = server.requests[0];
xhr.respond(400, {}, "");
- expect(error.calledWith("", 400)).toBe(true);
+ expect(error.calledWith("", 400)).to.be(true);
});
it("should call error on 500 response", function() {
@@ -180,7 +148,7 @@ define(["cane/net/request"], function(request) {
var xhr = server.requests[0];
xhr.respond(500, {}, "");
- expect(error.calledWith("", 500)).toBe(true);
+ expect(error.calledWith("", 500)).to.be(true);
});
});
View
16 tests/style/spec-addClass.js
@@ -7,7 +7,7 @@ define(["cane/style/addClass"], function (addClass) {
addClass(node, "newClass");
- expect(node.className).toBe("newClass");
+ expect(node.className).to.be("newClass");
});
it("should add multiple classes to an element", function() {
@@ -15,7 +15,7 @@ define(["cane/style/addClass"], function (addClass) {
addClass(node, "one two");
- expect(node.className).toBe("one two");
+ expect(node.className).to.be("one two");
});
it("should merge classes with existing classes", function() {
@@ -23,7 +23,7 @@ define(["cane/style/addClass"], function (addClass) {
node.className = "one two";
addClass(node, "one three");
- expect(node.className).toBe("one two three");
+ expect(node.className).to.be("one two three");
});
it("should add classes to array of nodes", function() {
@@ -32,23 +32,23 @@ define(["cane/style/addClass"], function (addClass) {
addClass([node1, node2], "one two");
- expect(node1.className).toBe("one two");
- expect(node2.className).toBe("one two");
+ expect(node1.className).to.be("one two");
+ expect(node2.className).to.be("one two");
});
it("should add classes to NodeList", function() {
var body = document.body,
node1 = document.createElement("h1"),
node2 = document.createElement("h1");
-
+
body.appendChild(node1);
body.appendChild(node2);
var list = document.getElementsByTagName("h1");
addClass(list, "one two");
- expect(node1.className).toBe("one two");
- expect(node2.className).toBe("one two");
+ expect(node1.className).to.be("one two");
+ expect(node2.className).to.be("one two");
body.removeChild(node1);
body.removeChild(node2);
View
16 tests/style/spec-css.js
@@ -5,7 +5,7 @@ define(["cane/style/css"], function(css) {
it("should add one style in key value format", function() {
var node = document.createElement("div");
css(node, "overflow", "hidden");
- expect(node.style.overflow).toBe("hidden");
+ expect(node.style.overflow).to.be("hidden");
});
it("should add multiple style settings passed as object", function() {
@@ -18,10 +18,10 @@ define(["cane/style/css"], function(css) {
"lineHeight": "20px"
});
- expect(node.style.overflow).toBe("hidden");
- expect(node.style.height).toBe("30px");
- expect(node.style.width).toBe("20px");
- expect(node.style.lineHeight).toBe("20px");
+ expect(node.style.overflow).to.be("hidden");
+ expect(node.style.height).to.be("30px");
+ expect(node.style.width).to.be("20px");
+ expect(node.style.lineHeight).to.be("20px");
});
it("should normalize style", function() {
@@ -33,9 +33,9 @@ define(["cane/style/css"], function(css) {
"minWidth": "100px"
});
- expect(node.style.lineHeight).toBe("20px");
- expect(node.style.fontSize).toBe("10em");
- expect(node.style.minWidth).toBe("100px");
+ expect(node.style.lineHeight).to.be("20px");
+ expect(node.style.fontSize).to.be("10em");
+ expect(node.style.minWidth).to.be("100px");
});
});
View
12 tests/style/spec-hasClass.js
@@ -6,8 +6,8 @@ define(["cane/style/hasClass"], function (hasClass) {
var node = document.createElement("div");
node.className = "foo";
- expect( hasClass(node, "foo") ).toBe(true);
- expect( hasClass(node, "bar") ).toBe(false);
+ expect( hasClass(node, "foo") ).to.be(true);
+ expect( hasClass(node, "bar") ).to.be(false);
});
it("should check for multiple classes", function() {
@@ -17,8 +17,8 @@ define(["cane/style/hasClass"], function (hasClass) {
first.className = "foo bar woot";
second.className = "one two three";
- expect( hasClass(first, "bar woot foo") ).toBe(true);
- expect( hasClass(second, "five three") ).toBe(false);
+ expect( hasClass(first, "bar woot foo") ).to.be(true);
+ expect( hasClass(second, "five three") ).to.be(false);
});
it("should check on multiple elements", function() {
@@ -32,8 +32,8 @@ define(["cane/style/hasClass"], function (hasClass) {
var nodes = document.getElementsByTagName("h1");
- expect( hasClass(nodes, "two three") ).toBe(true);
- expect( hasClass(nodes, "two five") ).toBe(false);
+ expect( hasClass(nodes, "two three") ).to.be(true);
+ expect( hasClass(nodes, "two five") ).to.be(false);
});
});
View
12 tests/style/spec-removeClass.js
@@ -8,7 +8,7 @@ define(["cane/style/removeClass"], function(removeClass) {
removeClass(node, "one");
- expect(node.className).toBe("two");
+ expect(node.className).to.be("two");
});
it("should remove multiple classes from an element", function() {
@@ -17,7 +17,7 @@ define(["cane/style/removeClass"], function(removeClass) {
removeClass(node, "one three");
- expect(node.className).toBe("two");
+ expect(node.className).to.be("two");
});
it("should remove classes to array of nodes", function() {
@@ -28,8 +28,8 @@ define(["cane/style/removeClass"], function(removeClass) {
removeClass([node1, node2], "three two");
- expect(node1.className).toBe("one");
- expect(node2.className).toBe("four five");
+ expect(node1.className).to.be("one");
+ expect(node2.className).to.be("four five");
});
it("should add classes to NodeList", function() {
@@ -45,8 +45,8 @@ define(["cane/style/removeClass"], function(removeClass) {
removeClass(nodes, "three two");
- expect(node1.className).toBe("one");
- expect(node2.className).toBe("four five");
+ expect(node1.className).to.be("one");
+ expect(node2.className).to.be("four five");
body.removeChild(node1);
body.removeChild(node2);
View
12 tests/utils/spec-allNodes.js
@@ -8,7 +8,7 @@ define(["cane/utils/allNodes"], function(allNodes) {
allNodes(node, function(n) { results.push(n); });
- expect(results).toEqual([node]);
+ expect(results).to.eql([node]);
});
it("should call callback for each node in array of nodes", function() {
@@ -21,7 +21,7 @@ define(["cane/utils/allNodes"], function(allNodes) {
allNodes(nodes, function(n) { results.push(n); });
- expect(results).toEqual(nodes);
+ expect(results).to.eql(nodes);
});
it("should call callback for each node in NodeList", function() {
@@ -34,7 +34,7 @@ define(["cane/utils/allNodes"], function(allNodes) {
allNodes(parent.children, function(n) { results.push(n); });
- expect(results).toEqual([childOne, childTwo]);
+ expect(results).to.eql([childOne, childTwo]);
});
it("should recurse into nested lists", function() {
@@ -53,7 +53,7 @@ define(["cane/utils/allNodes"], function(allNodes) {
allNodes(items, function(n) { results.push(n); });
- expect(results).toEqual([
+ expect(results).to.eql([
items[0],
child,
items[2][0],
@@ -70,11 +70,11 @@ define(["cane/utils/allNodes"], function(allNodes) {
];
allNodes(node, function() {
- expect(this).toBe(context);
+ expect(this).to.be(context);
}, context);
allNodes(nodes, function() {
- expect(this).toBe(context);
+ expect(this).to.be(context);
}, context);
});
View
12 tests/utils/spec-isList.js
@@ -4,28 +4,28 @@ define(["cane/utils/isList"], function(isList) {
it("should return true for NodeList", function() {
var list = document.getElementsByTagName("div");
- expect(isList(list)).toBe(true);
+ expect(isList(list)).to.be(true);
});
it("should return true for array", function() {
- expect(isList([])).toBe(true);
+ expect(isList([])).to.be(true);
});
it("should return true for arguments", function() {
- expect(isList(arguments)).toBe(true);
+ expect(isList(arguments)).to.be(true);
});
it("should return false for Node", function() {
var element = document.createElement("div");
- expect(isList(element)).toBe(false);
+ expect(isList(element)).to.be(false);
});
it("should return false for object", function() {
- expect(isList({})).toBe(false);
+ expect(isList({})).to.be(false);
});
it("should return false for null", function() {
- expect(isList(null)).toBe(false);
+ expect(isList(null)).to.be(false);
});
});
View
14 tests/utils/spec-isNode.js
@@ -4,33 +4,33 @@ define(["cane/utils/isNode"], function(isNode) {
it("should return true for DOM elements", function() {
var element = document.createElement("div");
- expect(isNode(element)).toBe(true);
+ expect(isNode(element)).to.be(true);
});
it("should return true for text nodes", function() {
var node = document.createTextNode("test");
- expect(isNode(node)).toBe(true);
+ expect(isNode(node)).to.be(true);
});
it("should return true for document fragments", function() {
var node = document.createDocumentFragment();
- expect(isNode(node)).toBe(true);
+ expect(isNode(node)).to.be(true);
});
it("should return false for strings", function() {
- expect(isNode("<p>")).toBe(false);
+ expect(isNode("<p>")).to.be(false);
});
it("should return false for normal object", function() {
- expect(isNode({})).toBe(false);
+ expect(isNode({})).to.be(false);
});
it("should return false for RegExp", function() {
- expect(isNode(/test/)).toBe(false);
+ expect(isNode(/test/)).to.be(false);
});
it("should return false for null", function() {
- expect(isNode(null)).toBe(false);
+ expect(isNode(null)).to.be(false);
});
});
@conradz

:heart: all this code removal :+1:

Please sign in to comment.
Something went wrong with that request. Please try again.