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
14 changes: 7 additions & 7 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;
foo = true;

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
expect(foo).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 () {
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.be.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);
});
});
18 changes: 9 additions & 9 deletions koans/01--AboutArrays.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var expect = require('chai').expect,
FILL_ME_IN;
foo = "bar";

describe("About Arrays", function() {

//We shall contemplate truth by testing reality, via spec expectations.
it("should create arrays", function() {
var emptyArray = [];

expect(typeof(emptyArray)).to.equal(FILL_ME_IN);
expect(typeof(emptyArray)).to.equal('object');
// A mistake? - http://javascript.crockford.com/remedial.html

expect(emptyArray.length).to.equal(FILL_ME_IN);
expect(emptyArray.length).to.equal(0);

expect(emptyArray).to.be.empty;

Expand All @@ -24,19 +24,19 @@ describe("About Arrays", function() {
];

// What is the value of each element?
expect(multiTypeArray[0]).to.equal(FILL_ME_IN);
expect(multiTypeArray[0]).to.equal(0);

expect(multiTypeArray[2]).to.equal(FILL_ME_IN);
expect(multiTypeArray[2]).to.equal("two");

// Careful, this one is tricky... explain why!
expect( multiTypeArray[3]() ).to.equal(FILL_ME_IN);
expect( multiTypeArray[3]() ).to.equal(3);

expect(multiTypeArray[4].value1).to.equal(FILL_ME_IN);
expect(multiTypeArray[4].value1).to.equal(4);

// What are those brackets doing there?
expect(multiTypeArray[4]["value2"]).to.equal(FILL_ME_IN);
expect(multiTypeArray[4]["value2"]).to.equal(5);

expect(multiTypeArray[5][0]).to.equal(FILL_ME_IN);
expect(multiTypeArray[5][0]).to.equal(60);
});

it("should understand array literals", function () {
Expand Down