mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
2f37f0ca51
1) Add server mode validation in the binary path. 2) Updated preferences tree rendering to avoid using the ReactDOM render. 3) Updated CSS for keyboard shortcuts checkbox border makes it consistent with input box border. 4) Fixed jasmine test case and improved code coverage. 5) Fixed SonarQube issues. 6) Added validation to disable "Maximum column with" option if "Column sized by" option is set to "Column name" in Query Tool -> Result grid. 7) Updated documentation with the latest screenshots. 8) Correct typo in the documentation. Fixes #7261 refs #7149
113 lines
3.2 KiB
JavaScript
113 lines
3.2 KiB
JavaScript
/////////////////////////////////////////////////////////////
|
|
//
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
//
|
|
// Copyright (C) 2013 - 2022, The pgAdmin Development Team
|
|
// This software is released under the PostgreSQL Licence
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
import jasmineEnzyme from 'jasmine-enzyme';
|
|
import React from 'react';
|
|
import '../helper/enzyme.helper';
|
|
import { withTheme } from '../fake_theme';
|
|
import { createMount } from '@material-ui/core/test-utils';
|
|
import {
|
|
OutlinedInput,
|
|
} from '@material-ui/core';
|
|
import KeyboardShortcuts from '../../../pgadmin/static/js/components/KeyboardShortcuts';
|
|
import { InputCheckbox } from '../../../pgadmin/static/js/components/FormComponents';
|
|
|
|
/* MUI Components need to be wrapped in Theme for theme vars */
|
|
describe('KeyboardShortcuts', () => {
|
|
let mount;
|
|
let defult_value = {
|
|
'ctrl': true,
|
|
'alt': true,
|
|
'key': {
|
|
'char': 'a',
|
|
'key_code': 97
|
|
},
|
|
'shift': false
|
|
};
|
|
let fields = [{
|
|
type: 'keyCode',
|
|
label: 'Key'
|
|
}, {
|
|
name: 'shift',
|
|
label: 'Shift',
|
|
type: 'checkbox'
|
|
},
|
|
{
|
|
name: 'control',
|
|
label: 'Control',
|
|
type: 'checkbox'
|
|
},
|
|
{
|
|
name: 'alt',
|
|
label: 'Alt/Option',
|
|
type: 'checkbox'
|
|
}];
|
|
|
|
/* Use createMount so that material ui components gets the required context */
|
|
/* https://material-ui.com/guides/testing/#api */
|
|
beforeAll(() => {
|
|
mount = createMount();
|
|
});
|
|
|
|
afterAll(() => {
|
|
mount.cleanUp();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
jasmineEnzyme();
|
|
});
|
|
|
|
describe('KeyboardShortcuts', () => {
|
|
let ThemedFormInputKeyboardShortcuts = withTheme(KeyboardShortcuts), ctrl;
|
|
let onChange = jasmine.createSpy('onChange');
|
|
beforeEach(() => {
|
|
ctrl = mount(
|
|
<ThemedFormInputKeyboardShortcuts
|
|
value={defult_value}
|
|
fields={fields}
|
|
controlProps={{
|
|
extraprop: 'test',
|
|
keyDown: onChange
|
|
}}
|
|
onChange={onChange}
|
|
/>);
|
|
});
|
|
|
|
it('init', () => {
|
|
expect(ctrl.find(OutlinedInput).prop('value')).toBe('a');
|
|
});
|
|
|
|
it('Key change', (done) => {
|
|
ctrl.find(OutlinedInput).at(0).find('input').simulate('keydown', { key: '', keyCode: 32});
|
|
expect(onChange).toHaveBeenCalledWith({ ctrl: true, alt: true, key: { char: 'Space', key_code: 32 }, shift: false });
|
|
done();
|
|
});
|
|
|
|
it('Shift option', (done) => {
|
|
ctrl.find(InputCheckbox).at(0).find('input').simulate('change', { target: { checked: true, name: 'shift' } });
|
|
expect(onChange).toHaveBeenCalledWith({ ctrl: true, alt: true, key: { char: 'a', key_code: 97 }, shift: true });
|
|
done();
|
|
});
|
|
|
|
it('Ctrl option', (done) => {
|
|
ctrl.find(InputCheckbox).at(1).find('input').simulate('change', { target: { checked: false, name: 'ctrl' } });
|
|
expect(onChange).toHaveBeenCalledWith({ ctrl: false, alt: true, key: { char: 'a', key_code: 97 }, shift: false });
|
|
done();
|
|
});
|
|
|
|
|
|
it('Alt option', (done) => {
|
|
ctrl.find(InputCheckbox).at(2).find('input').simulate('change', { target: { checked: false, name: 'alt' } });
|
|
expect(onChange).toHaveBeenCalledWith({ ctrl: true, alt: false, key: { char: 'a', key_code: 97 }, shift: false });
|
|
done();
|
|
});
|
|
|
|
});
|
|
});
|