2018-03-02 09:05:04 -06:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2019-01-02 04:24:12 -06:00
|
|
|
// Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
2018-03-02 09:05:04 -06:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-06-29 09:20:33 -05:00
|
|
|
import {
|
|
|
|
setFocusToDebuggerEditor,
|
|
|
|
getProcedureId,
|
|
|
|
} from '../../pgadmin/tools/debugger/static/js/debugger_utils';
|
2018-03-02 09:05:04 -06:00
|
|
|
|
2018-06-29 09:20:33 -05:00
|
|
|
describe('setFocusToDebuggerEditor', function () {
|
2018-03-02 09:05:04 -06:00
|
|
|
let editor;
|
|
|
|
editor = jasmine.createSpyObj('editor', ['focus']);
|
|
|
|
|
|
|
|
let tab_key = {
|
|
|
|
which: 9,
|
|
|
|
keyCode: 9,
|
2018-04-30 07:21:57 -05:00
|
|
|
};
|
2018-03-02 09:05:04 -06:00
|
|
|
|
|
|
|
let enter_key = {
|
|
|
|
which: 13,
|
|
|
|
keyCode: 13,
|
2018-04-30 07:21:57 -05:00
|
|
|
};
|
2018-03-02 09:05:04 -06:00
|
|
|
|
2018-06-29 09:20:33 -05:00
|
|
|
describe('setFocusToDebuggerEditor', function () {
|
2018-03-02 09:05:04 -06:00
|
|
|
it('returns undefined if no command is passed', function () {
|
|
|
|
expect(setFocusToDebuggerEditor(editor, null)).toEqual(undefined);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-06-29 09:20:33 -05:00
|
|
|
describe('setFocusToDebuggerEditor', function () {
|
2018-03-02 09:05:04 -06:00
|
|
|
it('should call focus on editor', function () {
|
2018-04-30 07:21:57 -05:00
|
|
|
setFocusToDebuggerEditor(editor, enter_key);
|
2018-03-02 09:05:04 -06:00
|
|
|
expect(editor.focus).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-06-29 09:20:33 -05:00
|
|
|
describe('setFocusToDebuggerEditor', function () {
|
2018-03-02 09:05:04 -06:00
|
|
|
it('should not call focus on editor and returns undefined', function () {
|
|
|
|
expect(setFocusToDebuggerEditor(editor, tab_key)).toEqual(undefined);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-06-29 09:20:33 -05:00
|
|
|
|
|
|
|
describe('getProcedureId', function () {
|
|
|
|
let treeInfroProc = {
|
|
|
|
'procedure': {
|
|
|
|
'_id': 123,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
let treeInfroInvalidProcId = {
|
|
|
|
'procedure': {
|
|
|
|
'_id': null,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
let treeInfroEdbProc = {
|
|
|
|
'edbproc': {
|
|
|
|
'_id': 321,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
let fakeTreeInfro;
|
|
|
|
|
|
|
|
describe('Should return proper object id', function () {
|
|
|
|
it('returns valid procedure id', function () {
|
2019-03-14 10:11:16 -05:00
|
|
|
expect(getProcedureId(treeInfroProc)).toEqual(123);
|
2018-06-29 09:20:33 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('returns valid edbproc id', function () {
|
2019-03-14 10:11:16 -05:00
|
|
|
expect(getProcedureId(treeInfroEdbProc)).toEqual(321);
|
2018-06-29 09:20:33 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('returns undefined for fake tree info', function () {
|
2019-03-14 10:11:16 -05:00
|
|
|
expect(getProcedureId(fakeTreeInfro)).toEqual(undefined);
|
2018-06-29 09:20:33 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('returns undefined for invalid procedure id', function () {
|
2019-03-14 10:11:16 -05:00
|
|
|
expect(getProcedureId(treeInfroInvalidProcId)).toEqual(undefined);
|
2018-06-29 09:20:33 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|