Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Judkins committed Jan 24, 2024
1 parent 650e007 commit f2e08f5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions tests/lib/traverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -198,6 +229,7 @@ test('expandFunctionParams returns_async', t => {
});



test('filter', t => {
/** @type {(spec: chromeTypes.TypeSpec, id: string) => boolean} */
const filter = (spec, id) => {
Expand Down

0 comments on commit f2e08f5

Please sign in to comment.