Skip to content

Commit

Permalink
test: app protocol handler
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmaddock committed Nov 19, 2024
1 parent 6aa8c69 commit 9638071
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/renderer/app-spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,36 @@ describe('App component', () => {
});
});

describe('setupProtocolListeners()', () => {
it('handles registering new versions', () => {
const addEventListenerMock = window.ElectronFiddle
.addEventListener as any;
addEventListenerMock.mockClear();

app.setupProtocolListeners();

expect(addEventListenerMock).toHaveBeenCalledWith(
'register-local-version',
expect.anything(),
);

const callback = addEventListenerMock.mock.calls[0][1];
const addVersion = {
name: 'new-version',
path: '/version/build/path',
version: '123.0.0-local',
};
callback(addVersion);

expect(app.state.addLocalVersion).toHaveBeenCalledWith({
name: addVersion.name,
localPath: addVersion.path,
version: addVersion.version,
});
expect(app.state.setVersion).toHaveBeenCalledWith(addVersion.version);
});
});

describe('prompting to confirm replacing an unsaved fiddle', () => {
// make a second fiddle that differs from the first
const editorValues = createEditorValues();
Expand Down

0 comments on commit 9638071

Please sign in to comment.