insomnia/packages/insomnia-app/app/common/__tests__/electron-helpers.test.ts

26 lines
751 B
TypeScript
Raw Normal View History

import electron from 'electron';
2021-07-22 23:04:56 +00:00
import { clickLink } from '../electron-helpers';
/* eslint-disable no-restricted-properties */
describe('clickLink', () => {
it('should allow http links', () => {
const url = 'http://mockbin.org';
clickLink(url);
expect(electron.shell.openExternal).toHaveBeenCalledWith(url);
});
it('should allow https links', () => {
const url = 'https://mockbin.org';
clickLink(url);
expect(electron.shell.openExternal).toHaveBeenCalledWith(url);
});
it('should not allow smb links', () => {
const url = 'file:///C:/windows/system32/calc.exe';
clickLink(url);
expect(electron.shell.openExternal).not.toHaveBeenCalledWith(url);
});
});
/* eslint-enable no-restricted-properties */