Created
November 7, 2013 15:20
-
-
Save wiseman17/7356346 to your computer and use it in GitHub Desktop.
PromiseService usage - NO warning
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
define(function (require) { | |
var PromiseService = require("services/PromiseService"), | |
mockService, | |
promiseService, | |
promise, | |
testRootPath = '/testrootpath/', | |
success = false, | |
errorReason = false; | |
mockService = {}; | |
// mock call | |
mockService.loadRoot = function loadRoot(rootPath, callback) { | |
callback(false, true); | |
}; | |
promiseService = new PromiseService(mockService); | |
promise = promiseService.loadRoot(testRootPath); | |
promise.then( | |
function (result) { | |
success = result; | |
}, | |
function (error) { | |
errorReason = error; | |
} | |
); | |
/* After some async stuff */ | |
expect(success).toBeTruthy(); | |
expect(errorReason).toBeFalsy(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment