mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
Fixed Jasmine test cases.
This commit is contained in:
parent
2f37f0ca51
commit
7f2e87b27d
@ -93,7 +93,7 @@ function isValueEqual(val1, val2) {
|
||||
return (_.isEqual(val1, val2)
|
||||
|| ((val1 === null || _.isUndefined(val1)) && val2 === '')
|
||||
|| ((val1 === null || _.isUndefined(val1)) && typeof(val2) === 'boolean' && !val2)
|
||||
|| (attrDefined ? _.isEqual(val1.toString(), val2.toString()) : false
|
||||
|| (attrDefined ? (!_.isObject(val1) && _.isEqual(val1.toString(), val2.toString())) : false
|
||||
));
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ function getChangedData(topSchema, viewHelperProps, sessData, stringify=false, i
|
||||
|
||||
/* The comparator and setter */
|
||||
const attrChanged = (id, change, force=false)=>{
|
||||
if(isValueEqual(_.get(origVal, id), _.get(sessVal, id)) && !force && (_.isObject(_.get(origVal, id)) && _.isEqual(_.get(origVal, id), _.get(sessData, id)))) {
|
||||
if(isValueEqual(_.get(origVal, id), _.get(sessVal, id)) && !force) {
|
||||
return;
|
||||
} else {
|
||||
change = change || _.get(sessVal, id);
|
||||
|
@ -34,10 +34,7 @@ export default function SelectThemes({onChange, ...props}) {
|
||||
};
|
||||
|
||||
return (
|
||||
<Grid
|
||||
container
|
||||
direction="column"
|
||||
justifyContent="center">
|
||||
<Grid container direction="column">
|
||||
<Grid item lg={12} md={12} sm={12} xs={12}>
|
||||
<InputSelect ref={props.inputRef} onChange={themeChange} {...props} />
|
||||
</Grid>
|
||||
|
@ -196,7 +196,7 @@ describe('FormComponents', ()=>{
|
||||
it('init', ()=>{
|
||||
expect(ctrl.find(InputLabel).text()).toBe('First');
|
||||
expect(ctrl.find(CodeMirror).prop('value')).toEqual('thevalue');
|
||||
expect(ctrl.find(CodeMirror).prop('op1')).toEqual('test');
|
||||
expect(ctrl.find(CodeMirror).prop('options')).toEqual(jasmine.objectContaining({'op1': 'test'}));
|
||||
expect(ctrl.find(FormHelperText).text()).toBe('some help message');
|
||||
});
|
||||
});
|
||||
|
@ -15,6 +15,7 @@ export class FakeNode {
|
||||
serializeData() {return this.getData();}
|
||||
getPortName(attnum) {return `port-${attnum}`;}
|
||||
getPort() {return null;}
|
||||
getPorts() {return null;}
|
||||
addPort(obj) {return obj;}
|
||||
getColumnAt(pos) {return _.find(this.getColumns()||[], (c)=>c.attnum==pos);}
|
||||
remove() {/*This is intentional (SonarQube)*/}
|
||||
@ -45,3 +46,8 @@ export class FakeLink {
|
||||
setTargetPort() {/*This is intentional (SonarQube)*/}
|
||||
remove() {/*This is intentional (SonarQube)*/}
|
||||
}
|
||||
|
||||
export class FakePort {
|
||||
constructor() {}
|
||||
getLinks() {return null;}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import * as erdModule from 'pgadmin.tools.erd/erd_module';
|
||||
import erdPref from './erd_preferences';
|
||||
import BodyWidget from 'pgadmin.tools.erd/erd_tool/ui_components/BodyWidget';
|
||||
import * as ERDSqlTool from 'tools/datagrid/static/js/show_query_tool';
|
||||
import { FakeLink, FakeNode } from '../fake_item';
|
||||
import { FakeLink, FakeNode, FakePort } from '../fake_item';
|
||||
import Notify from '../../../../pgadmin/static/js/helpers/Notifier';
|
||||
|
||||
|
||||
@ -310,22 +310,25 @@ describe('ERD BodyWidget', ()=>{
|
||||
|
||||
it('onDeleteNode', (done)=>{
|
||||
let node = new FakeNode({name: 'table1', schema: 'erd1'});
|
||||
spyOn(node, 'remove');
|
||||
let link = new FakeLink({local_table_uid: 'tid1'});
|
||||
spyOn(link, 'remove');
|
||||
let port = new FakePort();
|
||||
spyOn(port, 'getLinks').and.returnValue([link]);
|
||||
spyOn(node, 'remove');
|
||||
spyOn(node, 'getPorts').and.returnValue([port]);
|
||||
let nodesDict = {
|
||||
'tid1': node
|
||||
};
|
||||
spyOn(bodyInstance.diagram, 'getModel').and.returnValue({
|
||||
'getNodesDict': ()=>nodesDict,
|
||||
});
|
||||
spyOn(bodyInstance.diagram, 'removeOneToManyLink');
|
||||
spyOn(bodyInstance.diagram, 'getSelectedNodes').and.returnValue([node]);
|
||||
spyOn(bodyInstance.diagram, 'getSelectedLinks').and.returnValue([link]);
|
||||
|
||||
bodyInstance.onDeleteNode();
|
||||
setTimeout(()=>{
|
||||
expect(node.remove).toHaveBeenCalled();
|
||||
expect(link.remove).toHaveBeenCalled();
|
||||
expect(bodyInstance.diagram.removeOneToManyLink).toHaveBeenCalledWith(link);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user