Skip to content

Commit

Permalink
test: add test for setJumpList arguments (#41650)
Browse files Browse the repository at this point in the history
test: add test for setJumpList arguments
  • Loading branch information
codebytere committed Mar 21, 2024
1 parent 00e3445 commit a32705f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
if (!delete_jump_list &&
!gin::ConvertFromV8(args->isolate(), val, &categories)) {
gin_helper::ErrorThrower(args->isolate())
.ThrowError("Argument must be null or an array of categories");
.ThrowTypeError("Argument must be null or an array of categories");
return JumpListResult::kArgumentError;
}

Expand Down
38 changes: 38 additions & 0 deletions spec/api-app-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,44 @@ describe('app module', () => {
});
});

ifdescribe(process.platform === 'win32')('setJumpList(categories)', () => {
it('throws an error when categories is not null or an array', () => {
expect(() => {
app.setJumpList('string' as any);
}).to.throw('Argument must be null or an array of categories');
});

it('can get jump list settings', () => {
const settings = app.getJumpListSettings();
expect(settings).to.eql({ minItems: 10, removedItems: [] });
});

it('can set a jump list with an array of categories', () => {
expect(() => {
app.setJumpList([
{ type: 'frequent' },
{
items: [{
type: 'task',
title: 'New Project',
program: process.execPath,
args: '--new-project',
description: 'Create a new project.'
},
{ type: 'separator' },
{
type: 'task',
title: 'Recover Project',
program: process.execPath,
args: '--recover-project',
description: 'Recover Project'
}]
}
]);
}).to.not.throw();
});
});

describe('getAppPath', () => {
it('works for directories with package.json', async () => {
const { appPath } = await runTestApp('app-path');
Expand Down

0 comments on commit a32705f

Please sign in to comment.