Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2019-10-14 14:47:33 -0400
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2019-10-18 09:55:11 -0400
commitd8c065817f6483d4791611d624d66ff47efa2f41 (patch)
treeb15f4be30a4d9c5aff2fa86ffaedd4e496e3589a /test
parent07c8b5547598ec129fa24656871abd0f0b2f54f7 (diff)
downloadliza-d8c065817f6483d4791611d624d66ff47efa2f41.tar.gz
liza-d8c065817f6483d4791611d624d66ff47efa2f41.tar.bz2
liza-d8c065817f6483d4791611d624d66ff47efa2f41.zip
NodeCallback<T, R>: New type to simplify callback declarations
Just trying to reduce some boilerplate. I kept this as a separate commit to illustrate clearly how this type of things is done since we'll have people learning TypeScript. * src/types/misc.ts (NodeCallback<T,R>): New type. * src/server/dapi/TokenedDataApi.ts: Use it. * test/server/dapi/TokenedDataApiTest.ts: Use it.
Diffstat (limited to 'test')
-rw-r--r--test/server/dapi/TokenedDataApiTest.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/server/dapi/TokenedDataApiTest.ts b/test/server/dapi/TokenedDataApiTest.ts
index bd2cfc8..558f699 100644
--- a/test/server/dapi/TokenedDataApiTest.ts
+++ b/test/server/dapi/TokenedDataApiTest.ts
@@ -121,9 +121,9 @@ describe( 'TokenedDataApi', () =>
const mock_dapi = new class implements DataApi
{
request(
- given_data: DataApiInput,
- callback: ( e: Error|null, data: DataApiResult|null ) => void,
- given_id: string
+ given_data: DataApiInput,
+ callback: NodeCallback<DataApiResult>,
+ given_id: string,
): this
{
expect( given_data ).to.equal( expected_data );
@@ -141,7 +141,7 @@ describe( 'TokenedDataApi', () =>
return mock_tstore;
};
- const callback = ( e: Error|null, data: DataApiResult|null ) =>
+ const callback: NodeCallback<DataApiResult> = ( e, data ) =>
{
expect( tok_completed ).to.be.true;
@@ -197,8 +197,8 @@ describe( 'TokenedDataApi', () =>
const mock_dapi = new class implements DataApi
{
request(
- _: any,
- callback: ( e: Error|null, data: DataApiResult|null ) => void,
+ _: any,
+ callback: NodeCallback<DataApiResult>,
)
{
callback( expected_err, null );
@@ -206,7 +206,7 @@ describe( 'TokenedDataApi', () =>
}
};
- const callback = ( e: Error|null, data: DataApiResult|null ) =>
+ const callback: NodeCallback<DataApiResult> = ( e, data ) =>
{
expect( data ).to.equal( null );
expect( e ).to.equal( expected_err );