Skip to content

Commit

Permalink
flow control, module tests wip; more objects tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmurphey committed Apr 12, 2012
1 parent 36c498b commit 8db0280
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tests/app/async.js
@@ -1,9 +1,9 @@
define([ 'jquery', 'use!underscore' ], function($, _) {
describe("async behavior", function() {
var promise, fn = function() { };
var promise, fn;

beforeEach(function() {

fn = function() { };
});

it("you should understand how to uses 'promises'", function(done) {
Expand Down Expand Up @@ -36,7 +36,5 @@ define([ 'jquery', 'use!underscore' ], function($, _) {

tests();
});

});

});
42 changes: 42 additions & 0 deletions tests/app/flowControl.js
@@ -0,0 +1,42 @@
define([ 'use!underscore' ], function(_) {
describe("flow control", function() {
var fn;

beforeEach(function() {
fn = function() { };
});

it("you should be able to conditionally branch your code", function() {
fn = function() {
// write a function that receives a number as its argument;
// if the number is divisible by 3, the function should return 'fizz';
// if the number is divisible by 5, the function should return 'buzz';
// if the number is divisible the 3 and 5, the function should return
// 'fizzbuzz';
// otherwise the function should return the number
};

// replace the following test with tests that prove your function works
expect(fn()).to.be.ok();
});

it("you should be able to work with logical operators", function() {
var and = function(val1, val2) {
// write a function that makes the tests below pass
},

or = function(val1, val2) {
// write a function that makes the tests below pass
};

expect(and(false, false)).not.to.be.ok();
expect(and(true, false)).not.to.be.ok();
expect(and(true, true)).to.be.ok();

expect(or(true, false)).to.be.ok();
expect(or(true, true)).to.be.ok();
expect(or(false, false)).not.to.be.ok();
});
});

});
17 changes: 17 additions & 0 deletions tests/app/modules.js
@@ -0,0 +1,17 @@
define([ 'use!underscore' ], function(_) {
describe("the module pattern", function() {
var fn = function() {};

it("you should be able to create a function that returns a module", function() {
fn = function() {
// write a function that makes the tests pass
};

var module = fn('hello', 'matt');
expect(module.name).to.be.ok();
expect(module.greeting).to.be.ok();
expect(module.sayIt).to.be.a('function');
expect(module.sayIt()).to.be('hello, matt');
});
});
});
9 changes: 9 additions & 0 deletions tests/app/objects.js
Expand Up @@ -43,5 +43,14 @@ define([ 'use!underscore' ], function(_) {
expect(new C('Ellie').greeting).to.be(greeting);
});

it("you should be able to iterate over an object's properties", function() {
// define a function for fn so that the following will pass
var obj = {
foo : 'bar',
baz : 'bim'
};

expect(fn()).to.eql([ 'foo: bar', 'baz: bim' ]);
});
});
});

0 comments on commit 8db0280

Please sign in to comment.