Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

flow control, module tests wip; more objects tests

  • Loading branch information...
commit 8db02803da60f35daa571d17203c9c463641c6fe 1 parent 36c498b
@rmurphey rmurphey authored
View
6 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) {
@@ -36,7 +36,5 @@ define([ 'jquery', 'use!underscore' ], function($, _) {
tests();
});
-
});
-
});
View
42 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();
+ });
+ });
+
+});
View
17 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');
+ });
+ });
+});
View
9 tests/app/objects.js
@@ -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' ]);
+ });
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.