Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions koans/00--AboutExpects.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
var expect = require('chai').expect,
FILL_ME_IN;

describe("About Expects", function() {
describe("About Expects", function () {
// We shall contemplate truth by testing reality, via spec expectations.
it("should expect true", function() {
expect(FILL_ME_IN).to.be.true; //This should be true
it("should expect true", function () {
expect(true).to.be.true; //This should be true
});

// To understand reality, we must compare our expectations against reality.
it("should expect equality", function () {
var actual = 1 + 1;

expect(actual === FILL_ME_IN).to.be.true
expect(actual === 2).to.be.true
});

// Some ways of asserting equality are better than others.
it("should assert equality a better way", function () {
it("should assert equality a better way", function () {
var actual = 1 + 1;

// to.equal() compares using "strict" equality (===)
expect(actual).to.equal(FILL_ME_IN);
expect(actual).to.equal(2);
});

// Sometimes you need to be really exact about what you "type."
it("should check the _type_ first", function () {
var actual = (1 + 1).toString();

// use to.be.a() to check the type of a value
expect(actual).to.be.a(FILL_ME_IN);
expect(actual).to.be.a('string');

expect(actual).to.be(1); // Fails?
expect(actual).to.equal('2'); // Fails?
});

// Sometimes we will ask you to fill in the values.
it("should have filled in values", function () {
expect(1 + 1).to.equal(FILL_ME_IN);
expect(1 + 1).to.equal(2);
});
});
22 changes: 11 additions & 11 deletions koans/02--AboutFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("About Functions", function() {
return a + b;
}

expect(add(1, 2)).to.equal(FILL_ME_IN);
expect(add(1, 2)).to.equal(3);
});

it("should know internal variables override outer variables", function () {
Expand All @@ -24,11 +24,11 @@ describe("About Functions", function() {
return message;
}

expect(getMessage()).to.equal(FILL_ME_IN);
expect(getMessage()).to.equal("Outer");

expect(overrideMessage()).to.equal(FILL_ME_IN);
expect(overrideMessage()).to.equal("Inner");

expect(message).to.equal(FILL_ME_IN);
expect(message).to.equal("Outer");
});

it("should have lexical scoping", function () {
Expand All @@ -45,7 +45,7 @@ describe("About Functions", function() {
return childfunction();
}

expect(parentfunction()).to.equal(FILL_ME_IN);
expect(parentfunction()).to.equal("local");
});

it("should use lexical scoping to synthesise functions", function () {
Expand All @@ -63,7 +63,7 @@ describe("About Functions", function() {

var mysteryFunction5 = makeMysteryFunction(5);

expect(mysteryFunction3(10) + mysteryFunction5(5)).to.equal(FILL_ME_IN);
expect(mysteryFunction3(10) + mysteryFunction5(5)).to.equal(23);
});

it("should allow extra function arguments", function () {
Expand All @@ -72,19 +72,19 @@ describe("About Functions", function() {
return firstArg;
}

expect(returnFirstArg("first", "second", "third")).to.equal(FILL_ME_IN);
expect(returnFirstArg("first", "second", "third")).to.equal("first");

function returnSecondArg(firstArg, secondArg) {
return secondArg;
}

expect(returnSecondArg("only give first arg")).to.equal(FILL_ME_IN);
expect(returnSecondArg("only give first arg")).to.equal(undefined);

function returnAllArgs() {
return [].slice.call(arguments);
}

expect(returnAllArgs("first", "second", "third")).to.deep.equal(FILL_ME_IN);
expect(returnAllArgs("first", "second", "third")).to.deep.equal["first", "second","third"];
});

it("should pass functions as values", function () {
Expand All @@ -99,11 +99,11 @@ describe("About Functions", function() {

var praiseSinger = { givePraise: appendRules };

expect(praiseSinger.givePraise("John")).to.equal(FILL_ME_IN);
expect(praiseSinger.givePraise("John")).to.equal("John rules!");

praiseSinger.givePraise = appendDoubleRules;

expect(praiseSinger.givePraise("Mary")).to.equal(FILL_ME_IN);
expect(praiseSinger.givePraise("Mary")).to.equal("Mary totally rules!");

});
});