Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding more tests revealed my approach was completely wrong, so I need an awesome hack instead.
- Loading branch information
Showing
5 changed files
with
64 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
"use strict" | |||
|
|||
Q = require("q") | |||
chai = require("chai") | |||
chaiAsPromised = require("chai-as-promised") | |||
|
|||
chai.use(chaiAsPromised) | |||
|
|||
describe "Use with Chai as Promised", => | |||
it ".should.be.fulfilled", => | |||
Q.resolve().should.be.fulfilled | |||
it ".should.be.rejected", => | |||
Q.reject().should.be.rejected | |||
it ".should.be.rejected.with(TypeError, 'boo')", => | |||
Q.reject(new TypeError("boo!")).should.be.rejected.with(TypeError, "boo") | |||
it ".should.become(5)", => | |||
Q.resolve(5).should.become(5) | |||
it ".should.eventually.be.above(2)", => | |||
Q.resolve(5).should.eventually.be.above(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
"use strict" | |||
|
|||
Q = require("q") | |||
|
|||
describe "Direct usage of promise-returning tests", => | |||
it "should work for a promise fulfilled with no value", => | |||
Q.resolve() | |||
|
|||
it "should work for a promise fulfilled with a value", => | |||
Q.resolve({}) | |||
|
|||
it "should run through an entire promise chain", => | |||
timeout = setTimeout( | |||
=> throw new Error("The timeout wasn't cleared, so the promise chain must not have run"), | |||
100 | |||
) | |||
|
|||
Q.delay(5).then => | |||
Q.delay(5).then => | |||
clearTimeout(timeout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,10 +1,8 @@ | |||
var chai = require("chai"); | var chai = require("chai"); | ||
var chaiAsPromised = require("chai-as-promised"); | |||
|
|
||
var mocha = require("mocha"); | var mocha = require("mocha"); | ||
var mochaAsPromised = require("../mocha-as-promised"); | var mochaAsPromised = require("../mocha-as-promised"); | ||
|
|
||
chai.use(chaiAsPromised); | |||
chai.should(); | chai.should(); | ||
|
|
||
mochaAsPromised(mocha); | mochaAsPromised(mocha); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters