2019-05-31 10:51:30 -05:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2023-01-02 00:23:55 -06:00
|
|
|
// Copyright (C) 2013 - 2023, The pgAdmin Development Team
|
2019-05-31 10:51:30 -05:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
import {pgBrowser} from 'pgadmin.browser.layout';
|
|
|
|
import 'wcdocker';
|
|
|
|
|
2022-09-08 07:38:58 -05:00
|
|
|
let wcDocker = window.wcDocker;
|
2019-05-31 10:51:30 -05:00
|
|
|
|
|
|
|
describe('layout related functions test', function() {
|
|
|
|
let menu_items = null;
|
|
|
|
let dummy_cache = [{
|
|
|
|
id: 2,
|
|
|
|
mid: 1,
|
|
|
|
module:'browser',
|
|
|
|
name:'lock_layout',
|
|
|
|
value: 'none',
|
|
|
|
}];
|
|
|
|
|
|
|
|
beforeEach(function(){
|
|
|
|
pgBrowser.preferences_cache = dummy_cache;
|
|
|
|
pgBrowser.docker = {
|
2022-01-12 06:02:20 -06:00
|
|
|
'lockLayout': ()=>{/*This is intentional (SonarQube)*/},
|
2019-05-31 10:51:30 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
_.extend(pgBrowser,{
|
2022-12-22 02:55:18 -06:00
|
|
|
'all_menus_cache': {
|
2019-05-31 10:51:30 -05:00
|
|
|
'file': {
|
|
|
|
'mnu_locklayout': {
|
|
|
|
'menu_items': [
|
2022-01-12 06:02:20 -06:00
|
|
|
{'name': 'mnu_lock_none', change_checked: ()=> {/*This is intentional (SonarQube)*/}},
|
|
|
|
{'name': 'mnu_lock_docking', change_checked: ()=> {/*This is intentional (SonarQube)*/}},
|
|
|
|
{'name': 'mnu_lock_full', change_checked: ()=> {/*This is intentional (SonarQube)*/}},
|
2019-05-31 10:51:30 -05:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-12-22 02:55:18 -06:00
|
|
|
menu_items = pgBrowser.all_menus_cache.file.mnu_locklayout.menu_items;
|
2019-05-31 10:51:30 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('for menu actions', function() {
|
|
|
|
beforeEach(function(){
|
|
|
|
spyOn(pgBrowser, 'lock_layout');
|
|
|
|
spyOn(pgBrowser, 'save_lock_layout');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('mnu_lock_none', function() {
|
|
|
|
pgBrowser.mnu_lock_none();
|
|
|
|
expect(pgBrowser.lock_layout).toHaveBeenCalledWith(pgBrowser.docker, 'none');
|
|
|
|
expect(pgBrowser.save_lock_layout).toHaveBeenCalledWith('none');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('mnu_lock_docking', function() {
|
|
|
|
pgBrowser.mnu_lock_docking();
|
|
|
|
expect(pgBrowser.lock_layout).toHaveBeenCalledWith(pgBrowser.docker, 'docking');
|
|
|
|
expect(pgBrowser.save_lock_layout).toHaveBeenCalledWith('docking');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('mnu_lock_full', function() {
|
|
|
|
pgBrowser.mnu_lock_full();
|
|
|
|
expect(pgBrowser.lock_layout).toHaveBeenCalledWith(pgBrowser.docker, 'full');
|
|
|
|
expect(pgBrowser.save_lock_layout).toHaveBeenCalledWith('full');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('lock_layout', function() {
|
|
|
|
let change_checked_test= function(menu_name) {
|
2022-01-18 03:19:54 -06:00
|
|
|
for(let mnu_val of menu_items) {
|
|
|
|
if(mnu_val.name == menu_name) {
|
|
|
|
expect(mnu_val.change_checked).toHaveBeenCalledWith(true);
|
2019-05-31 10:51:30 -05:00
|
|
|
} else {
|
2022-01-18 03:19:54 -06:00
|
|
|
expect(mnu_val.change_checked).toHaveBeenCalledWith(false);
|
2019-05-31 10:51:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(function(){
|
|
|
|
spyOn(pgBrowser.docker, 'lockLayout');
|
2022-01-18 03:19:54 -06:00
|
|
|
for(let mnu_val of menu_items) {
|
|
|
|
spyOn(mnu_val, 'change_checked');
|
2019-05-31 10:51:30 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it('none', function() {
|
|
|
|
pgBrowser.lock_layout(pgBrowser.docker, 'none');
|
|
|
|
expect(pgBrowser.docker.lockLayout).toHaveBeenCalledWith(wcDocker.LOCK_LAYOUT_LEVEL.NONE);
|
|
|
|
change_checked_test('mnu_lock_none');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('docking', function() {
|
|
|
|
pgBrowser.lock_layout(pgBrowser.docker, 'docking');
|
|
|
|
expect(pgBrowser.docker.lockLayout).toHaveBeenCalledWith(wcDocker.LOCK_LAYOUT_LEVEL.PREVENT_DOCKING);
|
|
|
|
change_checked_test('mnu_lock_docking');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('full', function() {
|
|
|
|
pgBrowser.lock_layout(pgBrowser.docker, 'full');
|
|
|
|
expect(pgBrowser.docker.lockLayout).toHaveBeenCalledWith(wcDocker.LOCK_LAYOUT_LEVEL.FULL);
|
|
|
|
change_checked_test('mnu_lock_full');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|