From f2e08f5c55c480d8457cfa579d8d4bb1c31ff03d Mon Sep 17 00:00:00 2001 From: Tim Judkins Date: Wed, 24 Jan 2024 10:48:23 -0800 Subject: [PATCH] Add failing test --- package-lock.json | 4 ++-- tests/lib/traverse.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4c2e019..e37a1e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "chrome-types", + "name": "chrome-types-schema-change", "lockfileVersion": 2, "requires": true, "packages": { @@ -32,7 +32,7 @@ "check-code-coverage": "^1.10.0" }, "engines": { - "node": "16" + "node": ">=16" } }, "node_modules/@babel/code-frame": { diff --git a/tests/lib/traverse.js b/tests/lib/traverse.js index 72d7043..a546c09 100644 --- a/tests/lib/traverse.js +++ b/tests/lib/traverse.js @@ -152,6 +152,37 @@ test('expandFunctionParams returns', t => { }); +test('expandFunctionParams returns_async does_not_support_promises', t => { + const filter = () => true; + const tc = new traverse.TraverseContext(filter); + + /** @type {chromeTypes.TypeSpec} */ + const returnsAsyncFunction = { + type: 'function', + parameters: [ + { type: 'string', name: 's' }, + ], + returns_async: { + name: 'callback', + type: 'function', + does_not_support_promises: 'For testing', + parameters: [{ type: 'number', name: 'whatever' }], + }, + }; + + const returnsAsyncFunctionExpansions = tc.expandFunctionParams( + cloneObject(returnsAsyncFunction), + 'api:test', + ); + // Since this does not support promises, we expect to only get the callback signature. + t.deepEqual(returnsAsyncFunctionExpansions, [ + [ + { type: 'void', name: 'return' }, + { type: 'string', name: 's' }, + expectedOptionalReturnsAsync, + ] + ]); +}); test('expandFunctionParams returns_async', t => { const filter = () => true; @@ -198,6 +229,7 @@ test('expandFunctionParams returns_async', t => { }); + test('filter', t => { /** @type {(spec: chromeTypes.TypeSpec, id: string) => boolean} */ const filter = (spec, id) => {