mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed code smell 'Update this function so that its implementation is not identical' reported by SonarQube.
This commit is contained in:
parent
bc0b25d995
commit
b9e533e31a
@ -16,107 +16,65 @@ import '../../../pgadmin/misc/file_manager/static/js/select_dialogue.js';
|
|||||||
describe('fileSelectDialog', function () {
|
describe('fileSelectDialog', function () {
|
||||||
|
|
||||||
let params;
|
let params;
|
||||||
|
let calcWidth = (passed_width)=>{
|
||||||
pgAdmin.Browser = {
|
let iw = window.innerWidth;
|
||||||
stdW: {
|
if (iw > passed_width){
|
||||||
sm: 500,
|
return passed_width;
|
||||||
md: 700,
|
} else {
|
||||||
lg: 900,
|
if (iw > pgAdmin.Browser.stdW.lg)
|
||||||
default: 500,
|
return pgAdmin.Browser.stdW.lg;
|
||||||
calc: (passed_width) => {
|
else if (iw > pgAdmin.Browser.stdW.md)
|
||||||
let iw = window.innerWidth;
|
return pgAdmin.Browser.stdW.md;
|
||||||
if(iw > passed_width){
|
else if (iw > pgAdmin.Browser.stdW.sm)
|
||||||
return passed_width;
|
return pgAdmin.Browser.stdW.sm;
|
||||||
}else{
|
else
|
||||||
if (iw > pgAdmin.Browser.stdW.lg)
|
// if available screen resolution is still
|
||||||
return pgAdmin.Browser.stdW.lg;
|
// less then return the width value as it
|
||||||
else if (iw > pgAdmin.Browser.stdW.md)
|
return iw;
|
||||||
return pgAdmin.Browser.stdW.md;
|
}
|
||||||
else if (iw > pgAdmin.Browser.stdW.sm)
|
|
||||||
return pgAdmin.Browser.stdW.sm;
|
|
||||||
else
|
|
||||||
// if available screen resolution is still
|
|
||||||
// less then return the width value as it
|
|
||||||
return iw;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
stdH: {
|
|
||||||
sm: 200,
|
|
||||||
md: 400,
|
|
||||||
lg: 550,
|
|
||||||
default: 550,
|
|
||||||
calc: (passed_height) => {
|
|
||||||
// We are excluding sm as it is too small for dialog
|
|
||||||
let ih = window.innerHeight;
|
|
||||||
if (ih > passed_height){
|
|
||||||
return passed_height;
|
|
||||||
}else{
|
|
||||||
if (ih > pgAdmin.Browser.stdH.lg)
|
|
||||||
return pgAdmin.Browser.stdH.lg;
|
|
||||||
else if (ih > pgAdmin.Browser.stdH.md)
|
|
||||||
return pgAdmin.Browser.stdH.md;
|
|
||||||
else
|
|
||||||
// if available screen resolution is still
|
|
||||||
// less then return the height value as it
|
|
||||||
return ih;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let calcHeight = (passed_height)=>{
|
||||||
|
// We are excluding sm as it is too small for dialog
|
||||||
|
let ih = window.innerHeight;
|
||||||
|
if (ih > passed_height){
|
||||||
|
return passed_height;
|
||||||
|
}else{
|
||||||
|
if (ih > pgAdmin.Browser.stdH.lg)
|
||||||
|
return pgAdmin.Browser.stdH.lg;
|
||||||
|
else if (ih > pgAdmin.Browser.stdH.md)
|
||||||
|
return pgAdmin.Browser.stdH.md;
|
||||||
|
else
|
||||||
|
// if available screen resolution is still
|
||||||
|
// less then return the height value as it
|
||||||
|
return ih;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
pgAdmin.Browser = {
|
||||||
|
stdW: {
|
||||||
|
sm: 500,
|
||||||
|
md: 700,
|
||||||
|
lg: 900,
|
||||||
|
default: 500,
|
||||||
|
calc: (passed_width) => {
|
||||||
|
calcWidth(passed_width);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
stdH: {
|
||||||
|
sm: 200,
|
||||||
|
md: 400,
|
||||||
|
lg: 550,
|
||||||
|
default: 550,
|
||||||
|
calc: (passed_height) => {
|
||||||
|
calcHeight(passed_height);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
describe('When dialog is called for', () => {
|
describe('When dialog is called for', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
pgAdmin.Browser = {
|
|
||||||
stdW: {
|
|
||||||
sm: 500,
|
|
||||||
md: 700,
|
|
||||||
lg: 900,
|
|
||||||
default: 500,
|
|
||||||
calc: (passed_width) => {
|
|
||||||
let iw = window.innerWidth;
|
|
||||||
if(iw > passed_width){
|
|
||||||
return passed_width;
|
|
||||||
}else{
|
|
||||||
if (iw > pgAdmin.Browser.stdW.lg)
|
|
||||||
return pgAdmin.Browser.stdW.lg;
|
|
||||||
else if (iw > pgAdmin.Browser.stdW.md)
|
|
||||||
return pgAdmin.Browser.stdW.md;
|
|
||||||
else if (iw > pgAdmin.Browser.stdW.sm)
|
|
||||||
return pgAdmin.Browser.stdW.sm;
|
|
||||||
else
|
|
||||||
// if available screen resolution is still
|
|
||||||
// less then return the width value as it
|
|
||||||
return iw;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
stdH: {
|
|
||||||
sm: 200,
|
|
||||||
md: 400,
|
|
||||||
lg: 550,
|
|
||||||
default: 550,
|
|
||||||
calc: (passed_height) => {
|
|
||||||
// We are excluding sm as it is too small for dialog
|
|
||||||
let ih = window.innerHeight;
|
|
||||||
if (ih > passed_height){
|
|
||||||
return passed_height;
|
|
||||||
}else{
|
|
||||||
if (ih > pgAdmin.Browser.stdH.lg)
|
|
||||||
return pgAdmin.Browser.stdH.lg;
|
|
||||||
else if (ih > pgAdmin.Browser.stdH.md)
|
|
||||||
return pgAdmin.Browser.stdH.md;
|
|
||||||
else
|
|
||||||
// if available screen resolution is still
|
|
||||||
// less then return the height value as it
|
|
||||||
return ih;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Select file', function() {
|
it('Select file', function() {
|
||||||
params = {
|
params = {
|
||||||
'dialog_title': 'Select file',
|
'dialog_title': 'Select file',
|
||||||
@ -151,56 +109,6 @@ describe('fileSelectDialog', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('When dialog is called for storage file', () => {
|
describe('When dialog is called for storage file', () => {
|
||||||
beforeEach(() => {
|
|
||||||
pgAdmin.Browser = {
|
|
||||||
stdW: {
|
|
||||||
sm: 500,
|
|
||||||
md: 700,
|
|
||||||
lg: 900,
|
|
||||||
default: 500,
|
|
||||||
calc: (passed_width) => {
|
|
||||||
let iw = window.innerWidth;
|
|
||||||
if(iw > passed_width){
|
|
||||||
return passed_width;
|
|
||||||
}else{
|
|
||||||
if (iw > pgAdmin.Browser.stdW.lg)
|
|
||||||
return pgAdmin.Browser.stdW.lg;
|
|
||||||
else if (iw > pgAdmin.Browser.stdW.md)
|
|
||||||
return pgAdmin.Browser.stdW.md;
|
|
||||||
else if (iw > pgAdmin.Browser.stdW.sm)
|
|
||||||
return pgAdmin.Browser.stdW.sm;
|
|
||||||
else
|
|
||||||
// if available screen resolution is still
|
|
||||||
// less then return the width value as it
|
|
||||||
return iw;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
stdH: {
|
|
||||||
sm: 200,
|
|
||||||
md: 400,
|
|
||||||
lg: 550,
|
|
||||||
default: 550,
|
|
||||||
calc: (passed_height) => {
|
|
||||||
// We are excluding sm as it is too small for dialog
|
|
||||||
let ih = window.innerHeight;
|
|
||||||
if (ih > passed_height){
|
|
||||||
return passed_height;
|
|
||||||
}else{
|
|
||||||
if (ih > pgAdmin.Browser.stdH.lg)
|
|
||||||
return pgAdmin.Browser.stdH.lg;
|
|
||||||
else if (ih > pgAdmin.Browser.stdH.md)
|
|
||||||
return pgAdmin.Browser.stdH.md;
|
|
||||||
else
|
|
||||||
// if available screen resolution is still
|
|
||||||
// less then return the height value as it
|
|
||||||
return ih;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Storage file dialog', function() {
|
it('Storage file dialog', function() {
|
||||||
params = {
|
params = {
|
||||||
'dialog_title': 'Storage Manager',
|
'dialog_title': 'Storage Manager',
|
||||||
|
@ -187,7 +187,7 @@ describe('QueryHistory', () => {
|
|||||||
jasmine.clock().tick(1499);
|
jasmine.clock().tick(1499);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change the button text to \'Copied!\'', () => {
|
it('1.5 seconds should change the button text to \'Copied!\'', () => {
|
||||||
expect(copyAllButton().text()).toBe('Copied!');
|
expect(copyAllButton().text()).toBe('Copied!');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ describe('QueryHistory', () => {
|
|||||||
jasmine.clock().tick(1501);
|
jasmine.clock().tick(1501);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change the button text back to \'Copy\'', () => {
|
it('1.5 seconds should change the button text back to \'Copy\'', () => {
|
||||||
expect(copyAllButton().text()).toBe('Copy');
|
expect(copyAllButton().text()).toBe('Copy');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -41,6 +41,14 @@ describe('ExplainStatistics', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mouseClickAction = ()=> {
|
||||||
|
// Trigger mouse over event
|
||||||
|
var clickEvent = new $.Event('click');
|
||||||
|
$('.pg-explain-stats-area').trigger(clickEvent);
|
||||||
|
|
||||||
|
expect(tooltipContainer.hasClass('d-none')).toBe(false);
|
||||||
|
};
|
||||||
|
|
||||||
describe('JIT Statistics', () => {
|
describe('JIT Statistics', () => {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
$('body').append(statsDiv);
|
$('body').append(statsDiv);
|
||||||
@ -54,11 +62,7 @@ describe('ExplainStatistics', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Mouse click event should be trigger', () => {
|
it('Mouse click event should be trigger', () => {
|
||||||
// Trigger mouse over event
|
mouseClickAction();
|
||||||
var clickEvent = new $.Event('click');
|
|
||||||
$('.pg-explain-stats-area').trigger(clickEvent);
|
|
||||||
|
|
||||||
expect(tooltipContainer.hasClass('d-none')).toBe(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -75,11 +79,7 @@ describe('ExplainStatistics', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Mouse click event should be trigger', () => {
|
it('Mouse click event should be trigger', () => {
|
||||||
// Trigger mouse over event
|
mouseClickAction();
|
||||||
var clickEvent = new $.Event('click');
|
|
||||||
$('.pg-explain-stats-area').trigger(clickEvent);
|
|
||||||
|
|
||||||
expect(tooltipContainer.hasClass('d-none')).toBe(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -100,11 +100,7 @@ describe('ExplainStatistics', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Mouse click event should be trigger', () => {
|
it('Mouse click event should be trigger', () => {
|
||||||
// Trigger mouse over event
|
mouseClickAction();
|
||||||
var clickEvent = new $.Event('click');
|
|
||||||
$('.pg-explain-stats-area').trigger(clickEvent);
|
|
||||||
|
|
||||||
expect(tooltipContainer.hasClass('d-none')).toBe(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -13,6 +13,47 @@ import {
|
|||||||
import pgAdmin from 'sources/pgadmin';
|
import pgAdmin from 'sources/pgadmin';
|
||||||
import {TreeFake} from '../../tree/tree_fake';
|
import {TreeFake} from '../../tree/tree_fake';
|
||||||
|
|
||||||
|
let beforeActionForSchema = (tree, pgBrowser)=> {
|
||||||
|
let hierarchy = {
|
||||||
|
id: 'root',
|
||||||
|
children: [{
|
||||||
|
id: 'level2',
|
||||||
|
data: {_type: 'schema'},
|
||||||
|
children: [{
|
||||||
|
id: 'coll-table',
|
||||||
|
data: {_type: 'coll-table'},
|
||||||
|
children: [{
|
||||||
|
id: 'table/1',
|
||||||
|
data: {_type: 'table'},
|
||||||
|
}],
|
||||||
|
}],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
|
||||||
|
tree = TreeFake.build(hierarchy, pgBrowser);
|
||||||
|
pgBrowser.tree = tree;
|
||||||
|
};
|
||||||
|
|
||||||
|
let beforeActionForCatalog = (tree, pgBrowser)=> {
|
||||||
|
let hierarchy = {
|
||||||
|
id: 'root',
|
||||||
|
children: [{
|
||||||
|
id: 'level2',
|
||||||
|
data: {_type: 'catalog'},
|
||||||
|
children: [{
|
||||||
|
id: 'coll-table',
|
||||||
|
data: {_type: 'coll-table'},
|
||||||
|
children: [{
|
||||||
|
id: 'table/1',
|
||||||
|
data: {_type: 'table'},
|
||||||
|
}],
|
||||||
|
}],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
|
||||||
|
tree = TreeFake.build(hierarchy, pgBrowser);
|
||||||
|
pgBrowser.tree = tree;
|
||||||
|
};
|
||||||
|
|
||||||
describe('#childCreateMenuEnabled', () => {
|
describe('#childCreateMenuEnabled', () => {
|
||||||
let data,
|
let data,
|
||||||
@ -86,24 +127,7 @@ describe('#childCreateMenuEnabled', () => {
|
|||||||
|
|
||||||
describe(', on one of the child node under schema node ', () => {
|
describe(', on one of the child node under schema node ', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
let hierarchy = {
|
beforeActionForSchema(tree, pgBrowser);
|
||||||
id: 'root',
|
|
||||||
children: [{
|
|
||||||
id: 'level2',
|
|
||||||
data: {_type: 'schema'},
|
|
||||||
children: [{
|
|
||||||
id: 'coll-table',
|
|
||||||
data: {_type: 'coll-table'},
|
|
||||||
children: [{
|
|
||||||
id: 'table/1',
|
|
||||||
data: {_type: 'table'},
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
};
|
|
||||||
|
|
||||||
tree = TreeFake.build(hierarchy, pgBrowser);
|
|
||||||
pgBrowser.tree = tree;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it(' it is true', () => {
|
it(' it is true', () => {
|
||||||
@ -160,24 +184,7 @@ describe('#childCreateMenuEnabled', () => {
|
|||||||
|
|
||||||
describe(', on one of the child node under catalog node ', () => {
|
describe(', on one of the child node under catalog node ', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
let hierarchy = {
|
beforeActionForCatalog(tree, pgBrowser);
|
||||||
id: 'root',
|
|
||||||
children: [{
|
|
||||||
id: 'level2',
|
|
||||||
data: {_type: 'catalog'},
|
|
||||||
children: [{
|
|
||||||
id: 'coll-table',
|
|
||||||
data: {_type: 'coll-table'},
|
|
||||||
children: [{
|
|
||||||
id: 'table/1',
|
|
||||||
data: {_type: 'table'},
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
};
|
|
||||||
|
|
||||||
tree = TreeFake.build(hierarchy, pgBrowser);
|
|
||||||
pgBrowser.tree = tree;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it(' it is false', () => {
|
it(' it is false', () => {
|
||||||
@ -195,27 +202,9 @@ describe('#childDropMenuEnabled', () => {
|
|||||||
let tree,
|
let tree,
|
||||||
pgBrowser = pgAdmin.Browser;
|
pgBrowser = pgAdmin.Browser;
|
||||||
|
|
||||||
|
|
||||||
describe(' - the child node under schema node ', () => {
|
describe(' - the child node under schema node ', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
let hierarchy = {
|
beforeActionForSchema(tree, pgBrowser);
|
||||||
id: 'root',
|
|
||||||
children: [{
|
|
||||||
id: 'level2',
|
|
||||||
data: {_type: 'schema'},
|
|
||||||
children: [{
|
|
||||||
id: 'coll-table',
|
|
||||||
data: {_type: 'coll-table'},
|
|
||||||
children: [{
|
|
||||||
id: 'table/1',
|
|
||||||
data: {_type: 'table'},
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
};
|
|
||||||
|
|
||||||
tree = TreeFake.build(hierarchy, pgBrowser);
|
|
||||||
pgBrowser.tree = tree;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it(' it is true', () => {
|
it(' it is true', () => {
|
||||||
@ -227,24 +216,7 @@ describe('#childDropMenuEnabled', () => {
|
|||||||
|
|
||||||
describe('- the child node under the catalog node ', () => {
|
describe('- the child node under the catalog node ', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
let hierarchy = {
|
beforeActionForCatalog(tree, pgBrowser);
|
||||||
id: 'root',
|
|
||||||
children: [{
|
|
||||||
id: 'level2',
|
|
||||||
data: {_type: 'catalog'},
|
|
||||||
children: [{
|
|
||||||
id: 'coll-table',
|
|
||||||
data: {_type: 'coll-table'},
|
|
||||||
children: [{
|
|
||||||
id: 'table/1',
|
|
||||||
data: {_type: 'table'},
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
};
|
|
||||||
|
|
||||||
tree = TreeFake.build(hierarchy, pgBrowser);
|
|
||||||
pgBrowser.tree = tree;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it(' it is false', () => {
|
it(' it is false', () => {
|
||||||
|
@ -243,6 +243,11 @@ describe('FunctionSchema', ()=>{
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let initDataProc = ()=>Promise.resolve({
|
||||||
|
sysfunc: true,
|
||||||
|
type: 'procedure',
|
||||||
|
});
|
||||||
|
|
||||||
it('proiswindow visible', ()=>{
|
it('proiswindow visible', ()=>{
|
||||||
|
|
||||||
|
|
||||||
@ -285,12 +290,7 @@ describe('FunctionSchema', ()=>{
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let initData = ()=>Promise.resolve({
|
mount(getEditView(editSchemaObj, initDataProc));
|
||||||
sysfunc: true,
|
|
||||||
type: 'procedure',
|
|
||||||
});
|
|
||||||
|
|
||||||
mount(getEditView(editSchemaObj, initData));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('proiswindow visible', ()=>{
|
it('proiswindow visible', ()=>{
|
||||||
@ -389,13 +389,7 @@ describe('FunctionSchema', ()=>{
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let initData = ()=>Promise.resolve({
|
mount(getEditView(editSchemaObj, initDataProc));
|
||||||
sysfunc: true,
|
|
||||||
type: 'procedure',
|
|
||||||
});
|
|
||||||
|
|
||||||
mount(getEditView(editSchemaObj, initData));
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('probin visible', ()=>{
|
it('probin visible', ()=>{
|
||||||
|
@ -143,11 +143,15 @@ describe('SearchObjectsDialogWrapper', () => {
|
|||||||
spyOn(soDialogWrapper, 'setResultCount');
|
spyOn(soDialogWrapper, 'setResultCount');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let prepareAction = ()=> {
|
||||||
|
spyOn(soDialogWrapper, 'prepareDialog');
|
||||||
|
soDialogWrapper.prepare();
|
||||||
|
expect(soDialogWrapper.prepareDialog).not.toHaveBeenCalled();
|
||||||
|
};
|
||||||
|
|
||||||
context('no tree element is selected', () => {
|
context('no tree element is selected', () => {
|
||||||
it('does not prepare dialog', () => {
|
it('does not prepare dialog', () => {
|
||||||
spyOn(soDialogWrapper, 'prepareDialog');
|
prepareAction();
|
||||||
soDialogWrapper.prepare();
|
|
||||||
expect(soDialogWrapper.prepareDialog).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -157,9 +161,7 @@ describe('SearchObjectsDialogWrapper', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not prepare the dialog', () => {
|
it('does not prepare the dialog', () => {
|
||||||
spyOn(soDialogWrapper, 'prepareDialog');
|
prepareAction();
|
||||||
soDialogWrapper.prepare();
|
|
||||||
expect(soDialogWrapper.prepareDialog).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -132,11 +132,16 @@ describe('ColumnSelector', function () {
|
|||||||
$('body').find(container).remove();
|
$('body').find(container).remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let selectColumnAction = ()=> {
|
||||||
|
container.find('.slick-header-column:contains(some-column-name)').click();
|
||||||
|
|
||||||
|
var selectedRanges = cellSelectionModel.getSelectedRanges();
|
||||||
|
expectOnlyTheFirstColumnToBeSelected(selectedRanges);
|
||||||
|
};
|
||||||
|
|
||||||
describe('when the user clicks a column header', function () {
|
describe('when the user clicks a column header', function () {
|
||||||
it('selects the column', function () {
|
it('selects the column', function () {
|
||||||
container.find('.slick-header-column:contains(some-column-name)').click();
|
selectColumnAction();
|
||||||
var selectedRanges = cellSelectionModel.getSelectedRanges();
|
|
||||||
expectOnlyTheFirstColumnToBeSelected(selectedRanges);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('toggles a selected class to the header cell', function () {
|
it('toggles a selected class to the header cell', function () {
|
||||||
@ -287,10 +292,7 @@ describe('ColumnSelector', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('deselects the non-column range', function () {
|
it('deselects the non-column range', function () {
|
||||||
container.find('.slick-header-column:contains(some-column-name)').click();
|
selectColumnAction();
|
||||||
|
|
||||||
var selectedRanges = cellSelectionModel.getSelectedRanges();
|
|
||||||
expectOnlyTheFirstColumnToBeSelected(selectedRanges);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -54,6 +54,35 @@ describe('#handleQueryOutputKeyboardEvent', function () {
|
|||||||
handleQueryOutputKeyboardEvent = HandleQueryOutputKeyboardEvent.bind(window);
|
handleQueryOutputKeyboardEvent = HandleQueryOutputKeyboardEvent.bind(window);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let selectEntireGridAction = ()=> {
|
||||||
|
handleQueryOutputKeyboardEvent(event, slickEvent);
|
||||||
|
|
||||||
|
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
|
||||||
|
expect(grid.getSelectionModel().getSelectedRanges().length).toEqual(1);
|
||||||
|
};
|
||||||
|
|
||||||
|
let commandAAction = ()=> {
|
||||||
|
beforeEach(function () {
|
||||||
|
event.metaKey = true;
|
||||||
|
event.keyCode = 65;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('selects the entire grid to ranges', function () {
|
||||||
|
selectEntireGridAction();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let ctrlAAction = ()=> {
|
||||||
|
beforeEach(function () {
|
||||||
|
event.ctrlKey = true;
|
||||||
|
event.keyCode = 65;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('selects the entire grid to ranges', function () {
|
||||||
|
selectEntireGridAction();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
describe('when a range is selected', function () {
|
describe('when a range is selected', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
grid.getSelectionModel().setSelectedRanges([
|
grid.getSelectionModel().setSelectedRanges([
|
||||||
@ -62,17 +91,18 @@ describe('#handleQueryOutputKeyboardEvent', function () {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let copyCellContentAction = ()=> {
|
||||||
|
handleQueryOutputKeyboardEvent(event, slickEvent);
|
||||||
|
expect(clipboard.copyTextToClipboard).toHaveBeenCalledWith('\'0,0-cell-content\',\'0,1-cell-content\'\n\'2,0-cell-content\',\'2,1-cell-content\'');
|
||||||
|
};
|
||||||
|
|
||||||
describe('pressing Command + C', function () {
|
describe('pressing Command + C', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
event.metaKey = true;
|
event.metaKey = true;
|
||||||
event.keyCode = 67;
|
event.keyCode = 67;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('copies the cell content to the clipboard', function () {
|
it('copies the cell content to the clipboard', copyCellContentAction);
|
||||||
handleQueryOutputKeyboardEvent(event, slickEvent);
|
|
||||||
|
|
||||||
expect(clipboard.copyTextToClipboard).toHaveBeenCalledWith('\'0,0-cell-content\',\'0,1-cell-content\'\n\'2,0-cell-content\',\'2,1-cell-content\'');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('pressing Ctrl + C', function () {
|
describe('pressing Ctrl + C', function () {
|
||||||
@ -81,69 +111,15 @@ describe('#handleQueryOutputKeyboardEvent', function () {
|
|||||||
event.keyCode = 67;
|
event.keyCode = 67;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('copies the cell content to the clipboard', function () {
|
it('copies the cell content to the clipboard', copyCellContentAction);
|
||||||
handleQueryOutputKeyboardEvent(event, slickEvent);
|
|
||||||
|
|
||||||
expect(clipboard.copyTextToClipboard).toHaveBeenCalledWith('\'0,0-cell-content\',\'0,1-cell-content\'\n\'2,0-cell-content\',\'2,1-cell-content\'');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('pressing Command + A', function () {
|
describe('pressing Command + A', commandAAction);
|
||||||
beforeEach(function () {
|
describe('pressing Ctrl + A', ctrlAAction);
|
||||||
event.metaKey = true;
|
|
||||||
event.keyCode = 65;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('selects the entire grid to ranges', function () {
|
|
||||||
handleQueryOutputKeyboardEvent(event, slickEvent);
|
|
||||||
|
|
||||||
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
|
|
||||||
expect(grid.getSelectionModel().getSelectedRanges().length).toEqual(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('pressing Ctrl + A', function () {
|
|
||||||
beforeEach(function () {
|
|
||||||
event.ctrlKey = true;
|
|
||||||
event.keyCode = 65;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('selects the entire grid to ranges', function () {
|
|
||||||
handleQueryOutputKeyboardEvent(event, slickEvent);
|
|
||||||
|
|
||||||
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
|
|
||||||
expect(grid.getSelectionModel().getSelectedRanges().length).toEqual(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when no ranges are selected', function () {
|
describe('when no ranges are selected', function () {
|
||||||
describe('pressing Command + A', function () {
|
describe('pressing Command + A', commandAAction);
|
||||||
beforeEach(function () {
|
describe('pressing Ctrl + A', ctrlAAction);
|
||||||
event.metaKey = true;
|
|
||||||
event.keyCode = 65;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('selects the entire grid to ranges', function () {
|
|
||||||
handleQueryOutputKeyboardEvent(event, slickEvent);
|
|
||||||
|
|
||||||
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
|
|
||||||
expect(grid.getSelectionModel().getSelectedRanges().length).toEqual(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('pressing Ctrl + A', function () {
|
|
||||||
beforeEach(function () {
|
|
||||||
event.ctrlKey = true;
|
|
||||||
event.keyCode = 65;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('selects the entire grid to ranges', function () {
|
|
||||||
handleQueryOutputKeyboardEvent(event, slickEvent);
|
|
||||||
|
|
||||||
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
|
|
||||||
expect(grid.getSelectionModel().getSelectedRanges().length).toEqual(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -35,94 +35,98 @@ describe('#callRenderAfterPoll', () => {
|
|||||||
jasmine.clock().uninstall();
|
jasmine.clock().uninstall();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let expectAction = (expectObj, callWithValue=null)=> {
|
||||||
|
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||||
|
if (callWithValue !== null) {
|
||||||
|
expect(expectObj).toHaveBeenCalledWith(callWithValue);
|
||||||
|
} else {
|
||||||
|
expect(expectObj).toHaveBeenCalledWith();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let queryResult1 = ()=>{
|
||||||
|
queryResult = {
|
||||||
|
rows_affected: 10,
|
||||||
|
has_more_rows: false,
|
||||||
|
colinfo: {},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
let queryResult2 = ()=>{
|
||||||
|
queryResult = {
|
||||||
|
rows_affected: 10,
|
||||||
|
has_more_rows: false,
|
||||||
|
colinfo: undefined,
|
||||||
|
result: 'Some result',
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
let displayNotificationAction = ()=> {
|
||||||
|
sqlEditorSpy.info_notifier_timeout = 10;
|
||||||
|
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||||
|
|
||||||
|
expect(Notify.success).toHaveBeenCalledWith(
|
||||||
|
'Query returned successfully in 0 msec.',
|
||||||
|
10
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
let saveAction = ()=> {
|
||||||
|
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
||||||
|
|
||||||
|
expect(sqlEditorSpy.update_msg_history).toHaveBeenCalledWith(
|
||||||
|
true,
|
||||||
|
'Some result\n\nQuery returned successfully in 0 msec.',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
describe('it is not a query tool', () => {
|
describe('it is not a query tool', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
sqlEditorSpy.is_query_tool = false;
|
sqlEditorSpy.is_query_tool = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('query was successful and have results', () => {
|
describe('query was successful and have results', () => {
|
||||||
beforeEach(() => {
|
beforeEach(queryResult1);
|
||||||
queryResult = {
|
|
||||||
rows_affected: 10,
|
|
||||||
has_more_rows: false,
|
|
||||||
colinfo: {},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders the editor', () => {
|
it('renders the editor', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy._render, queryResult);
|
||||||
|
|
||||||
expect(sqlEditorSpy._render).toHaveBeenCalledWith(queryResult);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inform sqleditor that the query stopped running', () => {
|
it('inform sqleditor that the query stopped running', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.setIsQueryRunning, false);
|
||||||
|
|
||||||
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hides the loading icon', () => {
|
it('hides the loading icon', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.trigger, 'pgadmin-sqleditor:loading-icon:hide');
|
||||||
|
|
||||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('query was successful but had no result to display', () => {
|
describe('query was successful but had no result to display', () => {
|
||||||
beforeEach(() => {
|
beforeEach(queryResult2);
|
||||||
queryResult = {
|
|
||||||
rows_affected: 10,
|
|
||||||
has_more_rows: false,
|
|
||||||
colinfo: undefined,
|
|
||||||
result: 'Some result',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('saves execution information in the history', () => {
|
it('saves execution information in the history', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
saveAction();
|
||||||
|
|
||||||
expect(sqlEditorSpy.update_msg_history).toHaveBeenCalledWith(
|
|
||||||
true,
|
|
||||||
'Some result\n\nQuery returned successfully in 0 msec.',
|
|
||||||
false
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('resets the changed data store', () => {
|
it('resets the changed data store', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.reset_data_store);
|
||||||
|
|
||||||
expect(sqlEditorSpy.reset_data_store).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inform sqleditor that the query stopped running', () => {
|
it('inform sqleditor that the query stopped running', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.setIsQueryRunning, false);
|
||||||
|
|
||||||
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hides the loading icon', () => {
|
it('hides the loading icon', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.trigger, 'pgadmin-sqleditor:loading-icon:hide');
|
||||||
|
|
||||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('notifications are enabled', () => {
|
describe('notifications are enabled', () => {
|
||||||
it('display notification', () => {
|
it('display notification', displayNotificationAction);
|
||||||
sqlEditorSpy.info_notifier_timeout = 10;
|
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
|
||||||
|
|
||||||
expect(Notify.success).toHaveBeenCalledWith(
|
|
||||||
'Query returned successfully in 0 msec.',
|
|
||||||
10
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('disables the save results button', () => {
|
it('disables the save results button', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.enable_disable_download_btn, true);
|
||||||
|
|
||||||
expect(sqlEditorSpy.enable_disable_download_btn).toHaveBeenCalledWith(true);
|
|
||||||
|
|
||||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -134,99 +138,54 @@ describe('#callRenderAfterPoll', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('query was successful and have results', () => {
|
describe('query was successful and have results', () => {
|
||||||
beforeEach(() => {
|
beforeEach(queryResult1);
|
||||||
queryResult = {
|
|
||||||
rows_affected: 10,
|
|
||||||
has_more_rows: false,
|
|
||||||
colinfo: {},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders the editor', () => {
|
it('renders the editor', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy._render, queryResult);
|
||||||
|
|
||||||
expect(sqlEditorSpy._render).toHaveBeenCalledWith(queryResult);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inform sqleditor that the query stopped running', () => {
|
it('inform sqleditor that the query stopped running', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.setIsQueryRunning, false);
|
||||||
|
|
||||||
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hides the loading icon', () => {
|
it('hides the loading icon', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.trigger, 'pgadmin-sqleditor:loading-icon:hide');
|
||||||
|
|
||||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('enables sqleditor tools buttons', () => {
|
it('enables sqleditor tools buttons', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.disable_tool_buttons, false);
|
||||||
|
|
||||||
expect(sqlEditorSpy.disable_tool_buttons).toHaveBeenCalledWith(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('query was successful but had no result to display', () => {
|
describe('query was successful but had no result to display', () => {
|
||||||
beforeEach(() => {
|
beforeEach(queryResult2);
|
||||||
queryResult = {
|
|
||||||
rows_affected: 10,
|
|
||||||
has_more_rows: false,
|
|
||||||
colinfo: undefined,
|
|
||||||
result: 'Some result',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('saves execution information in the history', () => {
|
it('saves execution information in the history', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
saveAction();
|
||||||
|
|
||||||
expect(sqlEditorSpy.update_msg_history).toHaveBeenCalledWith(
|
|
||||||
true,
|
|
||||||
'Some result\n\nQuery returned successfully in 0 msec.',
|
|
||||||
false
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('resets the changed data store', () => {
|
it('resets the changed data store', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.reset_data_store);
|
||||||
|
|
||||||
expect(sqlEditorSpy.reset_data_store).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('inform sqleditor that the query stopped running', () => {
|
it('inform sqleditor that the query stopped running', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.setIsQueryRunning, false);
|
||||||
|
|
||||||
expect(sqlEditorSpy.setIsQueryRunning).toHaveBeenCalledWith(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hides the loading icon', () => {
|
it('hides the loading icon', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.trigger, 'pgadmin-sqleditor:loading-icon:hide');
|
||||||
|
|
||||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('enables sqleditor tools buttons', () => {
|
it('enables sqleditor tools buttons', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.disable_tool_buttons, false);
|
||||||
|
|
||||||
expect(sqlEditorSpy.disable_tool_buttons).toHaveBeenCalledWith(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('notifications are enabled', () => {
|
describe('notifications are enabled', () => {
|
||||||
it('display notification', () => {
|
it('display notification', displayNotificationAction);
|
||||||
sqlEditorSpy.info_notifier_timeout = 10;
|
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
|
||||||
|
|
||||||
expect(Notify.success).toHaveBeenCalledWith(
|
|
||||||
'Query returned successfully in 0 msec.',
|
|
||||||
10
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('disables the save results button', () => {
|
it('disables the save results button', () => {
|
||||||
callRenderAfterPoll(sqlEditorSpy, Notify, queryResult);
|
expectAction(sqlEditorSpy.enable_disable_download_btn, true);
|
||||||
|
|
||||||
expect(sqlEditorSpy.enable_disable_download_btn).toHaveBeenCalledWith(true);
|
|
||||||
|
|
||||||
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
expect(sqlEditorSpy.trigger).toHaveBeenCalledWith('pgadmin-sqleditor:loading-icon:hide');
|
||||||
});
|
});
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -149,6 +149,35 @@ describe('the keyboard shortcuts', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let doesNothingTestCase = ()=> {
|
||||||
|
it('does nothing', () => {
|
||||||
|
keyboardShortcuts.processEventQueryTool(
|
||||||
|
sqlEditorControllerSpy, queryToolActionsSpy, event
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(queryToolActionsSpy.commentLineCode).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let beforeEachWindows = ()=> {
|
||||||
|
windowsKeysSetup();
|
||||||
|
event.which = FWD_SLASH_KEY;
|
||||||
|
event.shiftKey = true;
|
||||||
|
keyboardShortcuts.processEventQueryTool(
|
||||||
|
sqlEditorControllerSpy, queryToolActionsSpy, event
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
let beforeEachMAC = ()=> {
|
||||||
|
macKeysSetup();
|
||||||
|
event.which = FWD_SLASH_KEY;
|
||||||
|
event.shiftKey = true;
|
||||||
|
keyboardShortcuts.processEventQueryTool(
|
||||||
|
sqlEditorControllerSpy, queryToolActionsSpy, event
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
describe('when the key is not handled by the function', function () {
|
describe('when the key is not handled by the function', function () {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -395,13 +424,7 @@ describe('the keyboard shortcuts', () => {
|
|||||||
event.which = FWD_SLASH_KEY;
|
event.which = FWD_SLASH_KEY;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does nothing', () => {
|
doesNothingTestCase();
|
||||||
keyboardShortcuts.processEventQueryTool(
|
|
||||||
sqlEditorControllerSpy, queryToolActionsSpy, event
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(queryToolActionsSpy.commentLineCode).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('and the system is a Windows', () => {
|
describe('and the system is a Windows', () => {
|
||||||
@ -410,13 +433,7 @@ describe('the keyboard shortcuts', () => {
|
|||||||
event.which = FWD_SLASH_KEY;
|
event.which = FWD_SLASH_KEY;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does nothing', () => {
|
doesNothingTestCase();
|
||||||
keyboardShortcuts.processEventQueryTool(
|
|
||||||
sqlEditorControllerSpy, queryToolActionsSpy, event
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(queryToolActionsSpy.commentLineCode).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -465,12 +482,7 @@ describe('the keyboard shortcuts', () => {
|
|||||||
event.which = PERIOD_KEY;
|
event.which = PERIOD_KEY;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does nothing', () => {
|
doesNothingTestCase();
|
||||||
keyboardShortcuts.processEventQueryTool(
|
|
||||||
sqlEditorControllerSpy, queryToolActionsSpy, event
|
|
||||||
);
|
|
||||||
expect(queryToolActionsSpy.uncommentLineCode).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
describe('and the system is a Windows', () => {
|
describe('and the system is a Windows', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -478,13 +490,7 @@ describe('the keyboard shortcuts', () => {
|
|||||||
event.which = PERIOD_KEY;
|
event.which = PERIOD_KEY;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does nothing', () => {
|
doesNothingTestCase();
|
||||||
keyboardShortcuts.processEventQueryTool(
|
|
||||||
sqlEditorControllerSpy, queryToolActionsSpy, event
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(queryToolActionsSpy.uncommentLineCode).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -492,14 +498,7 @@ describe('the keyboard shortcuts', () => {
|
|||||||
describe('blockComment', () => {
|
describe('blockComment', () => {
|
||||||
describe('when there is not a query already running', () => {
|
describe('when there is not a query already running', () => {
|
||||||
describe('and the system is a Mac', () => {
|
describe('and the system is a Mac', () => {
|
||||||
beforeEach(() => {
|
beforeEach(beforeEachMAC);
|
||||||
macKeysSetup();
|
|
||||||
event.which = FWD_SLASH_KEY;
|
|
||||||
event.shiftKey = true;
|
|
||||||
keyboardShortcuts.processEventQueryTool(
|
|
||||||
sqlEditorControllerSpy, queryToolActionsSpy, event
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should comment out the block selection', () => {
|
it('should comment out the block selection', () => {
|
||||||
expect(queryToolActionsSpy.commentBlockCode).toHaveBeenCalledWith(sqlEditorControllerSpy);
|
expect(queryToolActionsSpy.commentBlockCode).toHaveBeenCalledWith(sqlEditorControllerSpy);
|
||||||
@ -511,14 +510,7 @@ describe('the keyboard shortcuts', () => {
|
|||||||
|
|
||||||
describe('when there is not a query already running', () => {
|
describe('when there is not a query already running', () => {
|
||||||
describe('and the system is a Windows', () => {
|
describe('and the system is a Windows', () => {
|
||||||
beforeEach(() => {
|
beforeEach(beforeEachWindows);
|
||||||
windowsKeysSetup();
|
|
||||||
event.which = FWD_SLASH_KEY;
|
|
||||||
event.shiftKey = true;
|
|
||||||
keyboardShortcuts.processEventQueryTool(
|
|
||||||
sqlEditorControllerSpy, queryToolActionsSpy, event
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should comment out the block selection', () => {
|
it('should comment out the block selection', () => {
|
||||||
expect(queryToolActionsSpy.commentBlockCode).toHaveBeenCalledWith(sqlEditorControllerSpy);
|
expect(queryToolActionsSpy.commentBlockCode).toHaveBeenCalledWith(sqlEditorControllerSpy);
|
||||||
@ -533,27 +525,13 @@ describe('the keyboard shortcuts', () => {
|
|||||||
sqlEditorControllerSpy.isQueryRunning.and.returnValue(true);
|
sqlEditorControllerSpy.isQueryRunning.and.returnValue(true);
|
||||||
});
|
});
|
||||||
describe('and the system is a Mac', () => {
|
describe('and the system is a Mac', () => {
|
||||||
beforeEach(() => {
|
beforeEach(beforeEachMAC);
|
||||||
macKeysSetup();
|
|
||||||
event.which = FWD_SLASH_KEY;
|
|
||||||
event.shiftKey = true;
|
|
||||||
keyboardShortcuts.processEventQueryTool(
|
|
||||||
sqlEditorControllerSpy, queryToolActionsSpy, event
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('does nothing', () => {
|
it('does nothing', () => {
|
||||||
expect(queryToolActionsSpy.commentBlockCode).not.toHaveBeenCalled();
|
expect(queryToolActionsSpy.commentBlockCode).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('and the system is a Windows', () => {
|
describe('and the system is a Windows', () => {
|
||||||
beforeEach(() => {
|
beforeEach(beforeEachWindows);
|
||||||
windowsKeysSetup();
|
|
||||||
event.which = FWD_SLASH_KEY;
|
|
||||||
event.shiftKey = true;
|
|
||||||
keyboardShortcuts.processEventQueryTool(
|
|
||||||
sqlEditorControllerSpy, queryToolActionsSpy, event
|
|
||||||
);
|
|
||||||
});
|
|
||||||
it('does nothing', () => {
|
it('does nothing', () => {
|
||||||
expect(queryToolActionsSpy.commentBlockCode).not.toHaveBeenCalled();
|
expect(queryToolActionsSpy.commentBlockCode).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -14,6 +14,27 @@ describe('queryToolActions', () => {
|
|||||||
selectedQueryString, entireQueryString,
|
selectedQueryString, entireQueryString,
|
||||||
replaceSelectionSpy;
|
replaceSelectionSpy;
|
||||||
|
|
||||||
|
let executeFunctionCall = ()=>{
|
||||||
|
queryToolActions.executeQuery(sqlEditorController);
|
||||||
|
expect(sqlEditorController.check_data_changes_to_execute_query).toHaveBeenCalled();
|
||||||
|
};
|
||||||
|
|
||||||
|
let toggleSelectionStringUpperCase = ()=> {
|
||||||
|
it('toggle the selection and string should be in upper case', () => {
|
||||||
|
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
|
||||||
|
expect(replaceSelectionSpy
|
||||||
|
).toHaveBeenCalledWith('STRING');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let beforeEachEmptySelection = ()=> {
|
||||||
|
setUpSpies('', 'a string\nddd\nsss');
|
||||||
|
|
||||||
|
sqlEditorController.gridView.query_tool_obj.getCursor = () => {
|
||||||
|
return 3;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
describe('executeQuery', () => {
|
describe('executeQuery', () => {
|
||||||
describe('when the command is being run from the query tool', () => {
|
describe('when the command is being run from the query tool', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -27,11 +48,7 @@ describe('queryToolActions', () => {
|
|||||||
expect(queryToolActions._clearMessageTab).toHaveBeenCalled();
|
expect(queryToolActions._clearMessageTab).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls the execute function on the sqlEditorController', () => {
|
it('calls the execute function on the sqlEditorController', executeFunctionCall);
|
||||||
queryToolActions.executeQuery(sqlEditorController);
|
|
||||||
|
|
||||||
expect(sqlEditorController.check_data_changes_to_execute_query).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
describe('when the command is being run from the view data view', () => {
|
describe('when the command is being run from the view data view', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -39,11 +56,7 @@ describe('queryToolActions', () => {
|
|||||||
sqlEditorController.is_query_tool = false;
|
sqlEditorController.is_query_tool = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('it calls the check_data_changes_to_execute_query function on the sqlEditorController', () => {
|
it('it calls the check_data_changes_to_execute_query function on the sqlEditorController', executeFunctionCall);
|
||||||
queryToolActions.executeQuery(sqlEditorController);
|
|
||||||
|
|
||||||
expect(sqlEditorController.check_data_changes_to_execute_query).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -279,29 +292,34 @@ describe('queryToolActions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when the table was opened through the queryTool', () => {
|
describe('when the table was opened through the queryTool', () => {
|
||||||
describe('when the query tool object has a selection', () => {
|
let time;
|
||||||
let time;
|
let spyCall = ()=> {
|
||||||
|
time = 'rightNow';
|
||||||
|
spyOn(window, 'Date').and.callFake(() => ({
|
||||||
|
getTime: () => {
|
||||||
|
return time;
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
let callCSVDownload = ()=> {
|
||||||
|
let filename = 'data-' + time + '.csv';
|
||||||
|
|
||||||
|
queryToolActions.download(sqlEditorController);
|
||||||
|
|
||||||
|
expect(sqlEditorController.trigger_csv_download).toHaveBeenCalledWith(filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('when the query tool object has a selection', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
entireQueryString = 'include some more of that yummy string cheese;';
|
entireQueryString = 'include some more of that yummy string cheese;';
|
||||||
selectedQueryString = 'some silly string cheese';
|
selectedQueryString = 'some silly string cheese';
|
||||||
setUpSpies(selectedQueryString, entireQueryString);
|
setUpSpies(selectedQueryString, entireQueryString);
|
||||||
|
|
||||||
time = 'rightNow';
|
spyCall();
|
||||||
spyOn(window, 'Date').and.callFake(() => ({
|
|
||||||
getTime: () => {
|
|
||||||
return time;
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls trigger_csv_download with filename having .csv extension', () => {
|
it('calls trigger_csv_download with filename having .csv extension', callCSVDownload);
|
||||||
let filename = 'data-' + time + '.csv';
|
|
||||||
|
|
||||||
queryToolActions.download(sqlEditorController);
|
|
||||||
|
|
||||||
expect(sqlEditorController.trigger_csv_download).toHaveBeenCalledWith(filename);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calls trigger_csv_download filename having .txt extension', () => {
|
it('calls trigger_csv_download filename having .txt extension', () => {
|
||||||
sqlEditorController.preferences.csv_field_separator = ';';
|
sqlEditorController.preferences.csv_field_separator = ';';
|
||||||
@ -314,29 +332,14 @@ describe('queryToolActions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when there is no selection', () => {
|
describe('when there is no selection', () => {
|
||||||
let time;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
selectedQueryString = '';
|
selectedQueryString = '';
|
||||||
entireQueryString = 'include some more of that yummy string cheese;';
|
entireQueryString = 'include some more of that yummy string cheese;';
|
||||||
|
|
||||||
setUpSpies(selectedQueryString, entireQueryString);
|
setUpSpies(selectedQueryString, entireQueryString);
|
||||||
|
spyCall();
|
||||||
time = 'rightNow';
|
|
||||||
spyOn(window, 'Date').and.callFake(() => ({
|
|
||||||
getTime: () => {
|
|
||||||
return time;
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls trigger_csv_download with filename', () => {
|
it('calls trigger_csv_download with filename', callCSVDownload);
|
||||||
let filename = 'data-' + time + '.csv';
|
|
||||||
|
|
||||||
queryToolActions.download(sqlEditorController);
|
|
||||||
|
|
||||||
expect(sqlEditorController.trigger_csv_download).toHaveBeenCalledWith(filename);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -369,13 +372,7 @@ describe('queryToolActions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when there is empty selection', () => {
|
describe('when there is empty selection', () => {
|
||||||
beforeEach(() => {
|
beforeEach(beforeEachEmptySelection);
|
||||||
setUpSpies('', 'a string\nddd\nsss');
|
|
||||||
|
|
||||||
sqlEditorController.gridView.query_tool_obj.getCursor = () => {
|
|
||||||
return 3;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('comments the current line', () => {
|
it('comments the current line', () => {
|
||||||
let codeMirrorObj = sqlEditorController.gridView.query_tool_obj;
|
let codeMirrorObj = sqlEditorController.gridView.query_tool_obj;
|
||||||
@ -416,13 +413,7 @@ describe('queryToolActions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when there is empty selection', () => {
|
describe('when there is empty selection', () => {
|
||||||
beforeEach(() => {
|
beforeEach(beforeEachEmptySelection);
|
||||||
setUpSpies('', 'a string\nddd\nsss');
|
|
||||||
|
|
||||||
sqlEditorController.gridView.query_tool_obj.getCursor = () => {
|
|
||||||
return 3;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('comments the current line', () => {
|
it('comments the current line', () => {
|
||||||
let codeMirrorObj = sqlEditorController.gridView.query_tool_obj;
|
let codeMirrorObj = sqlEditorController.gridView.query_tool_obj;
|
||||||
@ -463,13 +454,7 @@ describe('queryToolActions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when there is empty selection', () => {
|
describe('when there is empty selection', () => {
|
||||||
beforeEach(() => {
|
beforeEach(beforeEachEmptySelection);
|
||||||
setUpSpies('', 'a string\nddd\nsss');
|
|
||||||
|
|
||||||
sqlEditorController.gridView.query_tool_obj.getCursor = () => {
|
|
||||||
return 3;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('uncomments the current line', () => {
|
it('uncomments the current line', () => {
|
||||||
let codeMirrorObj = sqlEditorController.gridView.query_tool_obj;
|
let codeMirrorObj = sqlEditorController.gridView.query_tool_obj;
|
||||||
@ -496,31 +481,26 @@ describe('queryToolActions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('toggleCaseOfSelectedText', () => {
|
describe('toggleCaseOfSelectedText', () => {
|
||||||
|
|
||||||
|
let doesNothingTestCase = ()=> {
|
||||||
|
it('does nothing', () => {
|
||||||
|
expect(
|
||||||
|
queryToolActions.toggleCaseOfSelectedText(sqlEditorController)
|
||||||
|
).not.toBeDefined();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
describe('when there is no query text', () => {
|
describe('when there is no query text', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setUpSpies('', '');
|
setUpSpies('', '');
|
||||||
});
|
});
|
||||||
it('does nothing', () => {
|
doesNothingTestCase();
|
||||||
expect(
|
|
||||||
queryToolActions.toggleCaseOfSelectedText(sqlEditorController)
|
|
||||||
).not.toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when there is empty selection', () => {
|
describe('when there is empty selection', () => {
|
||||||
beforeEach(() => {
|
beforeEach(beforeEachEmptySelection);
|
||||||
setUpSpies('', 'a string\nddd\nsss');
|
|
||||||
|
|
||||||
sqlEditorController.gridView.query_tool_obj.getCursor = () => {
|
doesNothingTestCase();
|
||||||
return 3;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does nothing', () => {
|
|
||||||
expect(
|
|
||||||
queryToolActions.toggleCaseOfSelectedText(sqlEditorController)
|
|
||||||
).not.toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when selected query is in lower case', () => {
|
describe('when selected query is in lower case', () => {
|
||||||
@ -528,11 +508,7 @@ describe('queryToolActions', () => {
|
|||||||
setUpSpies('string', 'a string\nddd\nsss');
|
setUpSpies('string', 'a string\nddd\nsss');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('toggle the selection and string should be in upper case', () => {
|
toggleSelectionStringUpperCase();
|
||||||
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
|
|
||||||
expect(replaceSelectionSpy
|
|
||||||
).toHaveBeenCalledWith('STRING');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('(negative scenario toggle the selection and string should be in upper case', () => {
|
it('(negative scenario toggle the selection and string should be in upper case', () => {
|
||||||
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
|
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
|
||||||
@ -564,11 +540,7 @@ describe('queryToolActions', () => {
|
|||||||
setUpSpies('sTRIng', 'a string\nddd\nsss');
|
setUpSpies('sTRIng', 'a string\nddd\nsss');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('toggle the selection and string should be in upper case', () => {
|
toggleSelectionStringUpperCase();
|
||||||
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
|
|
||||||
expect(replaceSelectionSpy
|
|
||||||
).toHaveBeenCalledWith('STRING');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('(negative scenario toggle the selection and string should be in upper case', () => {
|
it('(negative scenario toggle the selection and string should be in upper case', () => {
|
||||||
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
|
queryToolActions.toggleCaseOfSelectedText(sqlEditorController);
|
||||||
|
@ -16,6 +16,15 @@ import {
|
|||||||
import {TreeFake} from '../tree/tree_fake';
|
import {TreeFake} from '../tree/tree_fake';
|
||||||
import {TreeNode} from '../../../pgadmin/static/js/tree/tree_nodes';
|
import {TreeNode} from '../../../pgadmin/static/js/tree/tree_nodes';
|
||||||
|
|
||||||
|
let beforeEachResponseError = (networkMock)=> {
|
||||||
|
networkMock.onPut(/.*/).reply(() => {
|
||||||
|
return [500, {
|
||||||
|
success: 0,
|
||||||
|
errormsg: 'some error message',
|
||||||
|
}];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
describe('#enableTriggers', () => {
|
describe('#enableTriggers', () => {
|
||||||
let networkMock;
|
let networkMock;
|
||||||
let tree;
|
let tree;
|
||||||
@ -120,12 +129,7 @@ describe('#enableTriggers', () => {
|
|||||||
|
|
||||||
describe('backend responds with error', () => {
|
describe('backend responds with error', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
networkMock.onPut(/.*/).reply(() => {
|
beforeEachResponseError(networkMock);
|
||||||
return [500, {
|
|
||||||
success: 0,
|
|
||||||
errormsg: 'some error message',
|
|
||||||
}];
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('displays an error alert', (done) => {
|
it('displays an error alert', (done) => {
|
||||||
@ -254,12 +258,7 @@ describe('#disableTriggers', () => {
|
|||||||
|
|
||||||
describe('backend responds with error', () => {
|
describe('backend responds with error', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
networkMock.onPut(/.*/).reply(() => {
|
beforeEachResponseError(networkMock);
|
||||||
return [500, {
|
|
||||||
success: 0,
|
|
||||||
errormsg: 'some error message',
|
|
||||||
}];
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('displays an error alert', (done) => {
|
it('displays an error alert', (done) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user