Permalink
Browse files

exchanges jasmine for mocha and expect.js

  • Loading branch information...
1 parent 06d561e commit 3dcbf4e14331e1f7a4f1decc47b2058d01bd4d02 @MathiasPaumgarten committed Oct 4, 2013
View
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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,38 +34,38 @@ 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() {
var one = document.createElement("span"),
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
@@ -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
@@ -4,18 +4,18 @@ 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() {
var first = document.createElement("div"),
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);
});
});
@@ -6,28 +6,28 @@ 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() {
var first = document.createElement("div"),
second = document.createElement("div");
first.className = "foo";
- expect( matches(".foo", first, second) ).toBe(false);
+ expect( matches(".foo", first, second) ).to.be(false);
});
});
View
@@ -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
@@ -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() {
@@ -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");
});
});
});
@@ -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);
});
});
Oops, something went wrong.

0 comments on commit 3dcbf4e

Please sign in to comment.