Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promises and ts1.6 (fixes #18, fixes #22) #20

Merged
merged 7 commits into from
Sep 29, 2015
40 changes: 21 additions & 19 deletions pouchdb-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,34 @@
/// <reference path="pouchdb-loose.d.ts" />
/// <reference path="pouchdb-plugins.d.ts" />

module promise {
class Foo {
foo: string;
}
module PouchDBTest {
module promise {
class Foo {
foo: string;
}

class fakePromise<T> implements pouchdb.async.Thenable<T> {
new() { }
class fakePromise<T> implements Promise<T> {
new() { }

then<R>(onFulfilled?: (value: T) => pouchdb.async.Thenable<R> | R, onRejected?: (error: any) => pouchdb.async.Thenable<R> | R) {
return new fakePromise<R>();
}
then<R>(onFulfilled?: (value: T) => Promise<R> | R, onRejected?: (error: any) => Promise<R> | R) {
return new fakePromise<R>();
}

catch<R>(onRejected: (error: any) => pouchdb.async.Thenable<R> | R) {
return undefined;
catch<R>(onRejected: (error: any) => Promise<R> | R) {
return undefined;
}

[Symbol.toStringTag]: string;
}
}

function chainedThen() {
var fooOut: string;
new PouchDB("dbname")
.then((db) => new fakePromise<Foo>())
.then((value: Foo) => { fooOut = value.foo; });
function chainedThen() {
var fooOut: string;
new PouchDB("dbname")
.then((db) => new fakePromise<Foo>())
.then((value: Foo) => { fooOut = value.foo; });
}
}
}

module PouchDBTest {
module localDb {
// common variables
var dbt: pouchdb.thenable.PouchDB;
Expand Down
Loading