1 var Q = require('../kew')
3 exports.testThen = function (test) {
4 var detectedScope = null
5 Q.resolve(true).then(function () {
8 test.ok(Q.isPromise(detectedScope), 'then() should be called in context of promise')
13 exports.testFail = function (test) {
14 var detectedScope = null
15 Q.reject(new Error()).fail(function () {
18 test.ok(Q.isPromise(detectedScope), 'fail() should be called in context of promise')
23 exports.testThenBound = function (test) {
24 var detectedScope = scope
26 Q.resolve(true).thenBound(function () {
28 }, scope).then(function () {
29 test.ok(detectedScope === scope, 'thenScoped() should be called in context of scope')
34 exports.testFailBound = function (test) {
35 var detectedScope = scope
37 Q.reject(new Error()).failBound(function () {
39 }, scope).then(function () {
40 test.equal(detectedScope, scope, 'failBound() should be called in context of scope')
45 exports.testThenBoundWithArgs = function (test) {
46 var detectedScope = scope
48 Q.resolve(-1).thenBound(function (a, b, c, d) {
54 }, scope, 1, 2, 3).then(function () {
55 test.ok(detectedScope === scope, 'failScoped() should be called in context of scope')