fix(core): update
This commit is contained in:
@ -1,19 +1,18 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartpromise from '../ts/index';
|
||||
import * as smartpromise from '../ts/index.js';
|
||||
|
||||
tap.test('should return a Deferred for .defer()', async () => {
|
||||
const myDeferred = smartpromise.defer();
|
||||
const expectPromise = expect(myDeferred.promise).to.eventually.be.fulfilled;
|
||||
myDeferred.resolve();
|
||||
return expectPromise;
|
||||
await myDeferred.promise;
|
||||
});
|
||||
|
||||
tap.test('should let types flow through the Promise', async () => {
|
||||
const myString = 'someString';
|
||||
const myDeferred = smartpromise.defer<string>();
|
||||
const expectPromise = expect(myDeferred.promise).to.eventually.equal('someString');
|
||||
myDeferred.resolve(myString);
|
||||
return expectPromise;
|
||||
const result = await myDeferred.promise;
|
||||
expect(result).toEqual('someString');
|
||||
});
|
||||
|
||||
tap.test('should map callbacks', async () => {
|
||||
@ -21,10 +20,8 @@ tap.test('should map callbacks', async () => {
|
||||
const myPromisified = async (myInput) => {
|
||||
return myInput;
|
||||
};
|
||||
const expectPromise = expect(
|
||||
smartpromise.map(inputArray, myPromisified)
|
||||
).to.eventually.deep.equal(inputArray);
|
||||
return expectPromise;
|
||||
const result = await smartpromise.map(inputArray, myPromisified);
|
||||
expect(result).toEqual(inputArray);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as smartpromise from '../ts';
|
||||
import * as smartpromise from '../ts/index.js';
|
||||
|
||||
// using Deferreds
|
||||
// simple deferred;
|
||||
@ -6,8 +6,7 @@ const done = smartpromise.defer();
|
||||
done.promise.then((stringArg) => {
|
||||
console.log(stringArg);
|
||||
});
|
||||
done.resolve('hello') // whenever you are ready
|
||||
|
||||
done.resolve('hello'); // whenever you are ready
|
||||
|
||||
// using deferreds in async functions to cater callback style apis
|
||||
const myAsyncFunction = async (): Promise<string> => {
|
||||
@ -48,7 +47,7 @@ smartpromise
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
import {tap, expect } from '@pushrocks/tapbundle';
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
tap.test('runs through', async () => {})
|
||||
tap.start();
|
||||
tap.test('runs through', async () => {});
|
||||
tap.start();
|
||||
|
Reference in New Issue
Block a user