Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2015 09 02 #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
12 changes: 6 additions & 6 deletions koans/00--AboutExpects.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ var expect = require('chai').expect,
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(true).to.be.true; //This should be true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about an explanation? Write one beneath the test in code comments...

});

// 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.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);
});
});
16 changes: 8 additions & 8 deletions koans/01--AboutArrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ describe("About Arrays", function() {
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey here's an example....

// The length of an empty array _must_ be 0, because it's empty.
// The `length` property is the count of the number of items in the array.


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(6);
});

it("should understand array literals", function () {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"dependencies": {
"chai": "^3.2.0",
"lodash": "^3.10.1",
"mocha": "^2.2.5"
"mocha": "^2.3.0"
}
}