Remove qcommon and added q.module.d.ts which declares a module 'q'. Also added a couple jasmine style tests.

This commit is contained in:
Andrew Gaspar committed 2013-03-23 16:22:55 -05:00
1 parent 362cefbcc0
commit 8fd794abff
3 files changed
+53 -58

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
/// <reference path="q.module.d.ts" />
/// <reference path="../jasmine/jasmine.d.ts" />
import q = module("q");
describe("q", function () {
it("should return", function (done) {
q({ myValue: true }).then(function (obj) {
if (obj.myValue) done();
else done("didn't work =(");
},
(err) => done(err));
});
it("should process all", function (done: (err?) => void) {
q.all([q(1), q(2), q(3)]).then(function (arr: number[]) {
var sum = arr.reduce(function (memo, cur) {
return memo + cur;
}, 0);
if (sum === 6) done();
else done({ actual: sum });
},
(err) => done(err));
});
});
+26
View File
@@ -0,0 +1,26 @@
/// <reference path="q.d.ts" />
module "q" {
export function try(method: Function, ...args: any[]): Qpromise;
export function fbind(method: Function, ...args: any[]): Qpromise;
export function fcall(method: Function, ...args: any[]): Qpromise;
export function all(promises: Qpromise[]): Qpromise;
export function allResolved(promises: Qpromise[]): Qpromise;
export function spread(onFulfilled: Function, onRejected: Function): Qpromise;
export function timeout(ms: number): Qpromise;
export function delay(ms: number): Qpromise;
export function delay(value: any, ms: number): Qpromise;
export function isFulfilled(): bool;
export function isRejected(): bool;
export function isPending(): bool;
export function valueOf(): any;
export function defer(): Qdeferred;
export function (value: any): Qpromise;
export function reject(): Qpromise;
export function promise(factory: { resolve: Function; reject: Function; notify: Function; }): Qpromise;
export function isPromise(value: any): bool;
export function async(generatorFunction: any): Qdeferred;
export function nextTick(callback: Function);
export var oneerror: any;
export var longStackJumpLimit: number;
}