Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bumped version, fixed tests to work with mocha ~1.0

  • Loading branch information...
commit 7d169d513c2d9e00342ea488f192141d49315f68 1 parent 0e28069
@lightsofapollo lightsofapollo authored
Showing with 20 additions and 28 deletions.
  1. +2 −2 package.json
  2. +18 −26 spec/mocha-hooks-spec.js
View
4 package.json
@@ -1,6 +1,6 @@
{
"name": "sinon-mocha",
- "version": "0.0.2",
+ "version": "0.0.3",
"author": "James Lal <james@lightsofapollo.com>",
"description": "Automatic restore for spies & mocks for mocha",
"main": "./lib/sinon-mocha",
@@ -14,7 +14,7 @@
"sinon"
],
"devDependencies": {
- "mocha" : "~0.12",
+ "mocha" : "~1.0",
"expect.js" : "*",
"sinon": "~1.3"
},
View
44 spec/mocha-hooks-spec.js
@@ -21,37 +21,36 @@ describe("mocha", function(){
describe("hooks firing", function(){
- var hooks = [], fn = function(){
- return function(){};
- };
-
- function getTitle(ctx){
- if(ctx._test){
- return ctx._test.title;
- } else {
- return ctx.title;
- }
- }
+ var beforeEachIndex = 0,
+ afterEachIndex = 0;
before(function(){
- hooks = [];
Hooks.beforeEach(function(){
- hooks.push('before - ' + getTitle(this));
+ beforeEachIndex++;
});
Hooks.afterEach(function(){
- hooks.push('after - ' + getTitle(this));
+ afterEachIndex++;
});
});
- it("one", fn());
+ it("one", function(){
+ expect(beforeEachIndex).to.be(1);
+ expect(afterEachIndex).to.be(0);
+ });
describe("testing nesting", function(){
- it("two", fn());
+ it("two", function(){
+ expect(beforeEachIndex).to.be(2);
+ expect(afterEachIndex).to.be(1);
+ });
describe("deep nesting", function(){
- it("three", fn());
+ it("three", function(){
+ expect(beforeEachIndex).to.be(3);
+ expect(afterEachIndex).to.be(2);
+ });
});
});
@@ -60,15 +59,8 @@ describe("mocha", function(){
Hooks._beforeEaches.pop();
Hooks._afterEaches.pop();
- //It should fire hooks in correct order
- expect(hooks).to.eql([
- 'before - one',
- 'after - one',
- 'before - two',
- 'after - two',
- 'before - three',
- 'after - three'
- ]);
+ expect(afterEachIndex).to.be(3);
+ expect(beforeEachIndex).to.be(3);
});
});

0 comments on commit 7d169d5

Please sign in to comment.
Something went wrong with that request. Please try again.