mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
d3ce502c13
* Install plugins from npm * A bit more * Error handling and messaging
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import * as plugin from '../app';
|
|
import * as modals from '../../../ui/components/modals';
|
|
import {globalBeforeEach} from '../../../__jest__/before-each';
|
|
|
|
const PLUGIN = {
|
|
name: 'my-plugin',
|
|
version: '1.0.0',
|
|
directory: '/plugins/my-plugin',
|
|
module: {}
|
|
};
|
|
|
|
describe('init()', () => {
|
|
beforeEach(globalBeforeEach);
|
|
it('initializes correctly', () => {
|
|
const result = plugin.init({name: PLUGIN});
|
|
expect(Object.keys(result)).toEqual(['app']);
|
|
expect(Object.keys(result.app)).toEqual(['alert', 'getPath', 'showSaveDialog']);
|
|
});
|
|
});
|
|
|
|
describe('app.alert()', () => {
|
|
beforeEach(globalBeforeEach);
|
|
it('shows alert with message', async () => {
|
|
modals.showAlert = jest.fn().mockReturnValue('dummy-return-value');
|
|
const result = plugin.init(PLUGIN);
|
|
|
|
// Make sure it returns result of showAlert()
|
|
expect(result.app.alert()).toBe('dummy-return-value');
|
|
expect(result.app.alert('My message')).toBe('dummy-return-value');
|
|
|
|
// Make sure it passes correct arguments
|
|
expect(modals.showAlert.mock.calls).toEqual([
|
|
[{message: '', title: 'Plugin my-plugin'}],
|
|
[{message: 'My message', title: 'Plugin my-plugin'}]
|
|
]);
|
|
});
|
|
});
|