pgadmin4/web/regression/javascript/components/ShortcutTitle.spec.js
Aditya Toshniwal b5b9ee46a1 1) Port query tool to React. Fixes #6131
2) Added status bar to the Query Tool. Fixes #3253
3) Ensure that row numbers should be visible in view when scrolling horizontally. Fixes #3989
4) Allow removing a single query history. Refs #4113
5) Partially fixed Macros usability issues. Ref #6969
6) Fixed an issue where the Query tool opens on minimum size if the user opens multiple query tool Window quickly. Fixes #6725
7) Relocate GIS Viewer Button to the Left Side of the Results Table. Fixes #6830
8) Fixed an issue where the connection bar is not visible. Fixes #7188
9) Fixed an issue where an Empty message popup after running a query. Fixes #7260
10) Ensure that Autocomplete should work after changing the connection. Fixes #7262
11) Fixed an issue where the copy and paste row does not work if the first column contains no data. Fixes #7294
2022-04-07 17:36:56 +05:30

86 lines
2.3 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 ShortcutTitle, { shortcutToString } from '../../../pgadmin/static/js/components/ShortcutTitle';
import * as keyShort from '../../../pgadmin/static/js/keyboard_shortcuts';
describe('ShortcutTitle', ()=>{
let mount;
/* 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();
});
const shortcut = {
'control': true,
'shift': true,
'alt': false,
'key': {
'key_code': 75,
'char': 'k',
},
};
it('ShortcutTitle', (done)=>{
let ThemedShortcutTitle = withTheme(ShortcutTitle);
spyOn(keyShort, 'isMac').and.returnValue(false);
let ctrl = mount(
<ThemedShortcutTitle
title="the title"
shortcut={shortcut}
/>);
setTimeout(()=>{
ctrl.update();
expect(ctrl.text()).toBe('the titleCtrlShiftK');
done();
}, 0);
});
describe('shortcutToString', ()=>{
it('shortcut', ()=>{
spyOn(keyShort, 'isMac').and.returnValue(false);
expect(shortcutToString(shortcut)).toBe('Ctrl + Shift + K');
});
it('shortcut as array', ()=>{
spyOn(keyShort, 'isMac').and.returnValue(false);
expect(shortcutToString(shortcut, null, true)).toEqual(['Ctrl', 'Shift', 'K']);
});
it('accesskey', ()=>{
spyOnProperty(window.navigator, 'userAgent').and.returnValue('Unknown');
expect(shortcutToString(null, 'A')).toEqual('Accesskey + A');
});
it('both null', ()=>{
expect(shortcutToString(null, null)).toEqual('');
});
it('mac meta key', ()=>{
shortcut.ctrl_is_meta = true;
spyOn(keyShort, 'isMac').and.returnValue(true);
expect(shortcutToString(shortcut)).toBe('Cmd + Shift + K');
});
});
});