Update all Python and JS dependencies. Fixes #4019

This commit is contained in:
Khushboo Vashi
2019-03-14 15:11:16 +00:00
committed by Dave Page
parent c7b29d35ae
commit e4417229aa
133 changed files with 8649 additions and 8569 deletions

View File

@@ -19,6 +19,7 @@ Bug fixes
********* *********
| `Bug #3995 <https://redmine.postgresql.org/issues/3995>`_ - Avoid 'bogus varno' message from Postgres when viewing the SQL for a table with triggers. | `Bug #3995 <https://redmine.postgresql.org/issues/3995>`_ - Avoid 'bogus varno' message from Postgres when viewing the SQL for a table with triggers.
| `Bug #4019 <https://redmine.postgresql.org/issues/4019>`_ - Update all Python and JavaScript dependencies.
| `Bug #4052 <https://redmine.postgresql.org/issues/4052>`_ - Fix the online help button on the resource group dialogue. | `Bug #4052 <https://redmine.postgresql.org/issues/4052>`_ - Fix the online help button on the resource group dialogue.
| `Bug #4053 <https://redmine.postgresql.org/issues/4053>`_ - Enable the online help button on the index dialogue. | `Bug #4053 <https://redmine.postgresql.org/issues/4053>`_ - Enable the online help button on the index dialogue.
| `Bug #4054 <https://redmine.postgresql.org/issues/4054>`_ - Handle resultsets with zero columns correctly in the Query Tool. | `Bug #4054 <https://redmine.postgresql.org/issues/4054>`_ - Handle resultsets with zero columns correctly in the Query Tool.

File diff suppressed because it is too large Load Diff

View File

@@ -4,32 +4,33 @@
# ignored when building a PIP Wheel. # ignored when building a PIP Wheel.
############################################################################## ##############################################################################
blinker==1.4 blinker==1.4
Flask==0.12.4 Flask==1.0.2
Flask-Gravatar==0.5.0 Flask-Gravatar==0.5.0
Flask-Login==0.3.2 Flask-Login==0.4.1
Flask-Mail==0.9.1 Flask-Mail==0.9.1
Flask-Migrate==2.1.1 Flask-Migrate==2.4.0
Flask-Principal==0.4.0 Flask-Principal==0.4.0
Flask-SQLAlchemy==2.3.2 Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2 Flask-WTF==0.14.2
passlib==1.7.1 passlib==1.7.1
pytz==2018.3 pytz==2018.9
simplejson==3.13.2 simplejson==3.16.0
six>=1.11.0 six>=1.12.0
speaklater==1.3 speaklater==1.3
sqlparse==0.2.4 sqlparse==0.2.4
WTForms==2.1 WTForms==2.2.1
Flask-Paranoid==0.2.0 Flask-Paranoid==0.2.0
psutil==5.4.7 psutil==5.5.1
psycopg2>=2.7.4 psycopg2>=2.7.7
python-dateutil>=2.7.1 python-dateutil>=2.8.0
htmlmin==0.1.12 htmlmin==0.1.12
Flask-HTMLmin==1.3.2 Flask-HTMLmin==1.5.0
SQLAlchemy>=1.2.5 SQLAlchemy>=1.2.18
Flask-Security>=3.0.0 Flask-Security>=3.0.0
sshtunnel>=0.1.3 sshtunnel>=0.1.4
############################################################### ###############################################################
# Modules specifically required for Python2.7 # Modules specifically required for Python2.7
############################################################### ###############################################################
importlib==1.0.3; python_version <= '2.7' importlib==1.0.4; python_version <= '2.7'

View File

@@ -14,14 +14,9 @@ module.exports = {
'amd': true, 'amd': true,
'jasmine': true, 'jasmine': true,
}, },
'extends': [
'eslint:recommended',
],
'parserOptions': { 'parserOptions': {
'ecmaFeatures': { 'ecmaVersion': 2018,
'experimentalObjectRestSpread': true, 'sourceType': 'module',
},
'sourceType': 'module'
}, },
'plugins': [ 'plugins': [
], ],

View File

@@ -1,96 +1,98 @@
{ {
"license": "PostgreSQL", "license": "PostgreSQL",
"devDependencies": { "devDependencies": {
"axios-mock-adapter": "^1.14.1", "@babel/core": "~7.3.4",
"babel-core": "~6.24.0", "@babel/preset-env": "~7.3.4",
"babel-loader": "~7.1.2", "axios-mock-adapter": "^1.16.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-loader": "~8.0.5",
"babel-preset-es2015": "~6.24.0", "babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
"cross-env": "^5.0.1", "cross-env": "^5.2.0",
"eclint": "^2.3.0", "eclint": "^2.8.1",
"eslint": "3.19.0", "eslint": "5.15.1",
"extract-text-webpack-plugin": "^3.0.2", "file-loader": "^3.0.1",
"file-loader": "^0.11.2", "image-webpack-loader": "^4.6.0",
"image-webpack-loader": "^3.3.1",
"is-docker": "^1.1.0", "is-docker": "^1.1.0",
"jasmine-core": "~2.99.0", "jasmine-core": "~3.3.0",
"karma": "~2.0.0", "karma": "^4.0.1",
"karma-babel-preprocessor": "^7.0.0", "karma-babel-preprocessor": "^8.0.0",
"karma-browserify": "~5.2.0", "karma-browserify": "~6.0.0",
"karma-chrome-launcher": "^2.2.0", "karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "~1.1.1", "karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^0.2.2", "karma-jasmine-html-reporter": "^1.4.0",
"karma-requirejs": "~1.1.0", "karma-requirejs": "~1.1.0",
"karma-source-map-support": "^1.3.0", "karma-source-map-support": "^1.4.0",
"karma-sourcemap-loader": "^0.3.7", "karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "~2.0.13", "karma-webpack": "~4.0.0-rc.6",
"node-sass": "^4.5.3", "mini-css-extract-plugin": "^0.5.0",
"optimize-css-assets-webpack-plugin": "^2.0.0", "node-sass": "^4.11.0",
"popper.js": "^1.14.4", "optimize-css-assets-webpack-plugin": "^5.0.1",
"raw-loader": "^0.5.1", "popper.js": "^1.14.7",
"raw-loader": "^1.0.0",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"sass-resources-loader": "^1.3.3", "sass-resources-loader": "^2.0.0",
"style-loader": "^0.18.2", "style-loader": "^0.23.1",
"uglifyjs-webpack-plugin": "^0.4.6", "uglifyjs-webpack-plugin": "^2.1.2",
"url-loader": "^0.5.9", "url-loader": "^1.1.2",
"webpack": "^3.0.0" "webpack": "^4.29.6",
"webpack-cli": "^3.2.3"
}, },
"dependencies": { "dependencies": {
"@babel/polyfill": "^7.2.5",
"acitree": "git+https://github.com/imsurinder90/jquery-aciTree.git#rc.7", "acitree": "git+https://github.com/imsurinder90/jquery-aciTree.git#rc.7",
"alertifyjs": "1.7.1", "alertifyjs": "1.7.1",
"axios": "^0.18.0", "axios": "^0.18.0",
"babel-plugin-transform-es2015-modules-amd": "^6.24.1", "babel-plugin-transform-es2015-modules-amd": "^6.24.1",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015-without-strict": "~0.0.4", "babel-preset-es2015-without-strict": "~0.0.4",
"babelify": "~7.3.0", "babelify": "~10.0.0",
"backbone": "1.3.3", "backbone": "1.4.0",
"backform": "^0.2.0", "backform": "^0.2.0",
"backgrid": "^0.3.8", "backgrid": "^0.3.8",
"backgrid-filter": "^0.3.7", "backgrid-filter": "^0.3.7",
"backgrid-select-all": "^0.3.5", "backgrid-select-all": "^0.3.5",
"backgrid-sizeable-columns": "^0.1.1", "backgrid-sizeable-columns": "^0.1.1",
"bignumber.js": "^6.0.0", "bignumber.js": "^8.1.1",
"bootstrap": "^4.1.3", "bootstrap": "^4.3.1",
"bootstrap-datepicker": "^1.7.0", "bootstrap-datepicker": "^1.8.0",
"bootstrap4-toggle": "3.4.0", "bootstrap4-toggle": "3.4.0",
"bowser": "1.6.1", "bowser": "2.1.2",
"browserify": "~14.1.0", "browserify": "~16.2.3",
"codemirror": "^5.43.0", "codemirror": "^5.44.0",
"css-loader": "0.14.0", "css-loader": "2.1.0",
"cssnano": "^3.10.0", "cssnano": "^4.1.10",
"dropzone": "^5.1.1", "dropzone": "^5.5.1",
"exports-loader": "~0.6.4", "exports-loader": "~0.7.0",
"flotr2": "git+https://github.com/EnterpriseDB/Flotr2.git", "flotr2": "git+https://github.com/EnterpriseDB/Flotr2.git",
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
"hard-source-webpack-plugin": "0.12.0", "fsevents": "^1.2.7",
"immutability-helper": "^2.2.0", "hard-source-webpack-plugin": "0.13.1",
"imports-loader": "^0.7.1", "immutability-helper": "^3.0.0",
"imports-loader": "^0.8.0",
"ip-address": "^5.8.9", "ip-address": "^5.8.9",
"jquery": "3.3.1", "jquery": "3.3.1",
"jquery-contextmenu": "^2.6.4", "jquery-contextmenu": "^2.8.0",
"jquery-ui": "^1.12.1", "jquery-ui": "^1.12.1",
"json-bignumber": "^1.0.1", "json-bignumber": "^1.0.1",
"leaflet": "^1.3.3", "leaflet": "^1.4.0",
"moment": "^2.20.1", "moment": "^2.24.0",
"moment-timezone": "^0.5.21", "moment-timezone": "^0.5.23",
"mousetrap": "^1.6.1", "mousetrap": "^1.6.3",
"prop-types": "^15.5.10", "prop-types": "^15.7.2",
"requirejs": "~2.3.3", "requirejs": "~2.3.6",
"select2": "^4.0.6-rc.1", "select2": "^4.0.6-rc.1",
"shim-loader": "^1.0.1", "shim-loader": "^1.0.1",
"slickgrid": "git+https://github.com/6pac/SlickGrid.git#2.3.16", "slickgrid": "git+https://github.com/6pac/SlickGrid.git#2.3.16",
"snapsvg": "^0.5.1", "snapsvg": "^0.5.1",
"spectrum-colorpicker": "^1.8.0", "spectrum-colorpicker": "^1.8.0",
"split.js": "^1.5.10", "split.js": "^1.5.10",
"sprintf-js": "^1.1.1", "sprintf-js": "^1.1.2",
"tablesorter": "^2.30.6", "tablesorter": "^2.31.1",
"tempusdominus-bootstrap-4": "^5.1.2", "tempusdominus-bootstrap-4": "^5.1.2",
"tempusdominus-core": "^5.0.3", "tempusdominus-core": "^5.0.3",
"underscore": "^1.8.3", "underscore": "^1.9.1",
"underscore.string": "^3.3.4", "underscore.string": "^3.3.5",
"watchify": "~3.9.0", "watchify": "~3.11.1",
"webcabin-docker": "git+https://github.com/EnterpriseDB/wcDocker/#9cf81f03bb350b76b77a264f1db5d55391d5e424", "webcabin-docker": "git+https://github.com/EnterpriseDB/wcDocker/#9cf81f03bb350b76b77a264f1db5d55391d5e424",
"wkx": "^0.4.5" "wkx": "^0.4.6"
}, },
"scripts": { "scripts": {
"linter": "yarn eslint --no-eslintrc -c .eslintrc.js --ext .js .", "linter": "yarn eslint --no-eslintrc -c .eslintrc.js --ext .js .",

View File

@@ -61,7 +61,7 @@ define('pgadmin.node.fts_configuration', [
}, },
}); });
// Customized control for token control // Customized control for token control
var TokenControl = Backform.TokenControl = var TokenControl = Backform.TokenControl =
Backform.UniqueColCollectionControl.extend({ Backform.UniqueColCollectionControl.extend({

View File

@@ -11,7 +11,7 @@ define([
'sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', 'backgrid', 'alertify', 'sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', 'backgrid', 'alertify',
'sources/pgadmin', 'pgadmin.browser.node', 'pgadmin.browser.node.ui', 'sources/pgadmin', 'pgadmin.browser.node', 'pgadmin.browser.node.ui',
], ],
function(gettext, _, $, Backbone, Backform, Backgrid, Alertify, pgAdmin, pgNode) { function(gettext, _, $, Backbone, Backform, Backgrid, Alertify, pgAdmin, pgNode) {
/* /*
* cellFunction for variable control. * cellFunction for variable control.
@@ -484,4 +484,4 @@ define([
}); });
return VariableModel; return VariableModel;
}); });

View File

@@ -9,7 +9,7 @@
define( define(
['sources/gettext', 'underscore', 'alertify', 'sources/pgadmin'], ['sources/gettext', 'underscore', 'alertify', 'sources/pgadmin'],
function(gettext, _, alertify, pgAdmin) { function(gettext, _, alertify, pgAdmin) {
pgAdmin.Browser = pgAdmin.Browser || {}; pgAdmin.Browser = pgAdmin.Browser || {};
_.extend(pgAdmin.Browser, { _.extend(pgAdmin.Browser, {
@@ -54,4 +54,4 @@ function(gettext, _, alertify, pgAdmin) {
}); });
return pgAdmin.Browser.report_error; return pgAdmin.Browser.report_error;
}); });

View File

@@ -9,10 +9,10 @@
import pgAdmin from 'sources/pgadmin'; import pgAdmin from 'sources/pgadmin';
import url_for from 'sources/url_for'; import url_for from 'sources/url_for';
import * as modifyAnimation from 'sources/modify_animation';
import $ from 'jquery'; import $ from 'jquery';
import * as Alertify from 'pgadmin.alertifyjs'; import * as Alertify from 'pgadmin.alertifyjs';
import * as SqlEditorUtils from 'sources/sqleditor_utils'; import * as SqlEditorUtils from 'sources/sqleditor_utils';
var modifyAnimation = require('sources/modify_animation');
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {}; const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};

View File

@@ -141,7 +141,7 @@ module.exports = Alertify.dialog('fileSelectionDlg', function() {
}, },
hooks: { hooks: {
onshow: function() { onshow: function() {
// $(this.elements.body).addClass('pgadmin-storage-body'); // $(this.elements.body).addClass('pgadmin-storage-body');
}, },
}, },
}; };

View File

@@ -296,22 +296,11 @@ function keyboardShortcutsQueryTool(
return panel_id; return panel_id;
} }
module.exports = { export {
processEventDebugger: keyboardShortcutsDebugger, keyboardShortcutsDebugger as processEventDebugger,
processEventQueryTool: keyboardShortcutsQueryTool, keyboardShortcutsQueryTool as processEventQueryTool,
getInnerPanel: getInnerPanel, getInnerPanel, validateShortcutKeys,
validateShortcutKeys: validateShortcutKeys, _stopEventPropagation, isMac, isKeyCtrlAlt, isKeyAltShift, isKeyCtrlShift,
// misc functions isKeyCtrlAltShift, isAltShiftBoth, isCtrlShiftBoth, isCtrlAltBoth,
_stopEventPropagation: _stopEventPropagation, shortcut_key, shortcut_title, shortcut_accesskey_title,
isMac: isMac,
isKeyCtrlAlt: isKeyCtrlAlt,
isKeyAltShift: isKeyAltShift,
isKeyCtrlShift: isKeyCtrlShift,
isKeyCtrlAltShift: isKeyCtrlAltShift,
isAltShiftBoth: isAltShiftBoth,
isCtrlShiftBoth: isCtrlShiftBoth,
isCtrlAltBoth: isCtrlAltBoth,
shortcut_key : shortcut_key,
shortcut_title : shortcut_title,
shortcut_accesskey_title : shortcut_accesskey_title,
}; };

View File

@@ -14,7 +14,7 @@ import Alertify from 'pgadmin.alertifyjs';
import pgAdmin from 'sources/pgadmin'; import pgAdmin from 'sources/pgadmin';
import Backform from 'pgadmin.backform'; import Backform from 'pgadmin.backform';
import axios from 'axios'; import axios from 'axios';
import queryToolActions from 'sources/sqleditor/query_tool_actions'; var queryToolActions = require('sources/sqleditor/query_tool_actions');
import filterDialogModel from 'sources/sqleditor/filter_dialog_model'; import filterDialogModel from 'sources/sqleditor/filter_dialog_model';
import {handleQueryToolAjaxError} from 'sources/sqleditor/query_tool_http_error_handler'; import {handleQueryToolAjaxError} from 'sources/sqleditor/query_tool_http_error_handler';

View File

@@ -13,7 +13,7 @@ import pgAdmin from 'sources/pgadmin';
import Backgrid from 'pgadmin.backgrid'; import Backgrid from 'pgadmin.backgrid';
import Backform from 'pgadmin.backform'; import Backform from 'pgadmin.backform';
let initModel = function(response) { export default function filterDialogModel(response) {
let order_mapping = { let order_mapping = {
'asc': gettext('ASC'), 'asc': gettext('ASC'),
@@ -135,7 +135,4 @@ let initModel = function(response) {
let model = new FilterCollectionModel(); let model = new FilterCollectionModel();
return model; return model;
}; }
module.exports = initModel;

View File

@@ -13,10 +13,10 @@ import url_for from 'sources/url_for';
import gettext from 'sources/gettext'; import gettext from 'sources/gettext';
import pgAdmin from 'sources/pgadmin'; import pgAdmin from 'sources/pgadmin';
const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {}; export const pgBrowser = pgAdmin.Browser = pgAdmin.Browser || {};
const browserTreeState = pgBrowser.browserTreeState = pgBrowser.browserTreeState || {}; export const browserTreeState = pgBrowser.browserTreeState = pgBrowser.browserTreeState || {};
_.extend(pgBrowser.browserTreeState, { _.extend(pgBrowser.browserTreeState, {
@@ -390,5 +390,3 @@ _.extend(pgBrowser.browserTreeState, {
} }
}, },
}); });
export {pgBrowser, browserTreeState};

View File

@@ -15,7 +15,7 @@ define([
'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser.node.ui', 'pgadmin.backform', 'pgadmin.backgrid', 'pgadmin.browser.node.ui',
], function( ], function(
gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, gettext, url_for, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
Backform, commonUtils, supportedNodes Backform, commonUtils, supportedNodes
) { ) {
pgAdmin = pgAdmin || window.pgAdmin || {}; pgAdmin = pgAdmin || window.pgAdmin || {};

View File

@@ -16,7 +16,7 @@ define('tools.restore', [
'tools/restore/static/js/restore_dialog', 'tools/restore/static/js/restore_dialog',
], function( ], function(
gettext, url_for, $, _, Backbone, S, alertify, pgBrowser, Backgrid, Backform, gettext, url_for, $, _, Backbone, S, alertify, pgBrowser, Backgrid, Backform,
commonUtils, menuUtils, supportedNodes, restoreDialog commonUtils, menuUtils, supportedNodes, restoreDialog
) { ) {
// if module is already initialized, refer to that. // if module is already initialized, refer to that.

View File

@@ -63,8 +63,12 @@ def getEncoding(key):
""" """
:param key: Database Encoding :param key: Database Encoding
:return: :return:
[Postgres_encoding, Python_encoding] - Postgres and Python encoding [Postgres_encoding, Python_encoding, typecast_encoding] -
Postgres encoding, Python encoding, type cast encoding
""" """
#
# Reference: https://www.postgresql.org/docs/11/multibyte.html
return encode_dict.get(key, ['UNICODE', 'utf-8', 'utf-8']) return encode_dict.get(key, ['UNICODE', 'utf-8', 'utf-8'])

View File

@@ -12,52 +12,50 @@ import gettext from 'sources/gettext';
describe('alertify_wrapper', function () { describe('alertify_wrapper', function () {
describe('success', function () { var env = jasmine.getEnv();
env.allowRespy(true);
describe('alertify_success', function () {
it('calls the success function from alertify and adds the checkmark to the element', function () { it('calls the success function from alertify and adds the checkmark to the element', function () {
spyOn(alertify, 'orig_success'); let spyObj = spyOn(alertify, 'orig_success').and.callThrough();
alertify.success('Yay, congrats!', 1); alertify.success('Yay, congrats!', 1);
var calledWithMessage = alertify.orig_success.calls.mostRecent().args[0]; expect(spyObj).toHaveBeenCalled();
expect(spyObj.calls.mostRecent().args[0]).toContain('Yay, congrats!');
expect(calledWithMessage).toContain('Yay, congrats!'); expect(spyObj.calls.mostRecent().args[0]).toContain('class="fa fa-check text-success"');
expect(calledWithMessage).toContain('class="fa fa-check text-success"');
}); });
}); });
describe('error', function () { describe('alertify_error calls the error function', function() {
it('calls the error function from alertify and adds the warning symbol to the element', function () { it('and adds the warning symbol to the element', function () {
spyOn(alertify, 'orig_error'); let spyOrigError = spyOn(alertify, 'orig_error').and.callThrough();
alertify.error('bad, very bad', 1); alertify.error('bad, very bad', 1);
var calledWithMessage = alertify.orig_error.calls.mostRecent().args[0]; expect(spyOrigError).toHaveBeenCalled();
expect(spyOrigError.calls.mostRecent().args[0]).toContain('bad, very bad');
expect(calledWithMessage).toContain('bad, very bad'); expect(spyOrigError.calls.mostRecent().args[0]).toContain('class="fa fa-exclamation-triangle text-danger"');
expect(calledWithMessage).toContain('class="fa fa-exclamation-triangle text-danger"');
}); });
}); });
describe('pgRespErrorNotify', () => { describe('alertify_error calls pgRespErrorNotify notifier', function() {
it('calls error notifier which alertifies response error for ajax calls', () => { it('which alertifies response error for ajax calls', () => {
$.ajax({ $.ajax({
url: 'http://some/dummy/url', url: 'http://some/dummy/url',
dataType: 'json', dataType: 'json',
error: function(xhr, status, error) { error: function(xhr, status, error) {
let spyOrigError = spyOn(alertify, 'orig_error').and.callThrough(),
spyOn(alertify, 'orig_error').and.callThrough(); spyNotify = spyOn(alertify, 'notify').and.callThrough();
spyOn(alertify, 'notify').and.callThrough();
/*When connection lost*/ /*When connection lost*/
xhr.status = 0; xhr.status = 0;
alertify.pgRespErrorNotify(xhr, error); alertify.pgRespErrorNotify(xhr, error);
expect(alertify.orig_error).toHaveBeenCalled(); expect(spyOrigError).toHaveBeenCalled();
expect(alertify.orig_error.calls.mostRecent().args[0]).toContain( expect(spyOrigError.calls.mostRecent().args[0]).toContain(
gettext('Connection to the server has been lost.') gettext('Connection to the server has been lost.')
); );
/*When some exception occurs at back end*/ /*When some exception occurs at back end*/
xhr.status = 4; xhr.status = 4;
var orig_getResponseHeader = xhr.getResponseHeader; var orig_getResponseHeader = xhr.getResponseHeader;
@@ -70,12 +68,11 @@ describe('alertify_wrapper', function () {
else { else {
return orig_getResponseHeader(header); return orig_getResponseHeader(header);
} }
}; };
xhr.responseText = '{"errormsg":"Exception XYZ"}'; xhr.responseText = '{"errormsg":"Exception XYZ"}';
alertify.pgRespErrorNotify(xhr, error); alertify.pgRespErrorNotify(xhr, error);
expect(alertify.orig_error).toHaveBeenCalled(); expect(spyOrigError).toHaveBeenCalled();
expect(alertify.orig_error.calls.mostRecent().args[0]).toContain( expect(spyOrigError.calls.mostRecent().args[0]).toContain(
gettext('Exception XYZ') gettext('Exception XYZ')
); );
@@ -90,8 +87,8 @@ describe('alertify_wrapper', function () {
}; };
xhr.responseText = '<p>Some Exception Occurred</p>'; xhr.responseText = '<p>Some Exception Occurred</p>';
alertify.pgRespErrorNotify(xhr, error); alertify.pgRespErrorNotify(xhr, error);
expect(alertify.notify).toHaveBeenCalled(); expect(spyNotify).toHaveBeenCalled();
expect(alertify.notify.calls.mostRecent().args[0]).toContain( expect(spyNotify.calls.mostRecent().args[0]).toContain(
gettext('INTERNAL SERVER ERROR') gettext('INTERNAL SERVER ERROR')
); );
@@ -106,8 +103,8 @@ describe('alertify_wrapper', function () {
}; };
xhr.responseText = '{"errormsg":"Exception XYZ"}'; xhr.responseText = '{"errormsg":"Exception XYZ"}';
alertify.pgRespErrorNotify(xhr, error, gettext('Some prefix message')); alertify.pgRespErrorNotify(xhr, error, gettext('Some prefix message'));
expect(alertify.orig_error).toHaveBeenCalled(); expect(spyOrigError).toHaveBeenCalled();
expect(alertify.orig_error.calls.mostRecent().args[0]).toContain( expect(spyOrigError.calls.mostRecent().args[0]).toContain(
gettext('Some prefix message') gettext('Some prefix message')
); );
}, },

View File

@@ -58,7 +58,7 @@ define([
it('keyboard shortcut control should be rendered with inner fields', function () { it('keyboard shortcut control should be rendered with inner fields', function () {
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy();
@@ -78,7 +78,7 @@ define([
it('when model "key" value changes UI and innerModel should update new "key" value', function (done) { it('when model "key" value changes UI and innerModel should update new "key" value', function (done) {
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.innerModel.get('key')).toEqual({ expect(control.innerModel.get('key')).toEqual({
'key_code': 73, 'key_code': 73,
'char': 'I', 'char': 'I',
@@ -98,7 +98,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
// this should change // this should change
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('A'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('A');
expect(control.innerModel.get('key')).toEqual({ expect(control.innerModel.get('key')).toEqual({
'key_code': 65, 'key_code': 65,
'char': 'A', 'char': 'A',
@@ -142,7 +142,7 @@ define([
expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy();
expect(control.innerModel.get('alt_option')).toBeTruthy(); expect(control.innerModel.get('alt_option')).toBeTruthy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.innerModel.get('key')).toEqual({ expect(control.innerModel.get('key')).toEqual({
'key_code': 73, 'key_code': 73,
'char': 'I', 'char': 'I',
@@ -179,7 +179,7 @@ define([
expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy();
expect(control.innerModel.get('alt_option')).toBeTruthy(); expect(control.innerModel.get('alt_option')).toBeTruthy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.innerModel.get('key')).toEqual({ expect(control.innerModel.get('key')).toEqual({
'key_code': 73, 'key_code': 73,
'char': 'I', 'char': 'I',
@@ -216,7 +216,7 @@ define([
expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy(); expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy();
expect(control.innerModel.get('shift')).toBeFalsy(); expect(control.innerModel.get('shift')).toBeFalsy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.innerModel.get('key')).toEqual({ expect(control.innerModel.get('key')).toEqual({
'key_code': 73, 'key_code': 73,
'char': 'I', 'char': 'I',
@@ -241,7 +241,7 @@ define([
it('when innerModel "key" value changes UI and model should update new "key" value', function (done) { it('when innerModel "key" value changes UI and model should update new "key" value', function (done) {
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(model.get(field.get('name'))).toEqual({ expect(model.get(field.get('name'))).toEqual({
'control': true, 'control': true,
'shift': false, 'shift': false,
@@ -262,7 +262,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
// this should change // this should change
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('A'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('A');
expect(model.get(field.get('name'))).toEqual({ expect(model.get(field.get('name'))).toEqual({
'control': true, 'control': true,
'shift': false, 'shift': false,
@@ -317,7 +317,7 @@ define([
// below three should not change. // below three should not change.
expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy(); expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy();
@@ -358,7 +358,7 @@ define([
// below three should not change. // below three should not change.
expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="alt_option"]')[0].checked).toBeTruthy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.$el.find('input:checkbox[name="control"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="control"]')[0].checked).toBeTruthy();
@@ -399,7 +399,7 @@ define([
// below three should not change. // below three should not change.
expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy(); expect(control.$el.find('input:checkbox[name="shift"]')[0].checked).toBeFalsy();
expect(control.$el.find('input:text[name="key"]')[0].value).toBe('I'); expect(control.$el.find('input:text[name="key"]')[0].value).toEqual('I');
expect(control.$el.find('input:checkbox[name="control"]')[0].checked).toBeTruthy(); expect(control.$el.find('input:checkbox[name="control"]')[0].checked).toBeTruthy();
@@ -424,7 +424,7 @@ define([
expect(control.cleanup).toHaveBeenCalled(); expect(control.cleanup).toHaveBeenCalled();
expect(control.controls.length).toBe(0); expect(control.controls.length).toEqual(0);
}); });

View File

@@ -75,7 +75,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
expect(control.$el.find('input')[0].value).toBe('A'); expect(control.$el.find('input')[0].value).toEqual('A');
done(); done();
}, 100); }, 100);
@@ -101,7 +101,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
expect(control.$el.find('input')[0].value).toBe('B'); expect(control.$el.find('input')[0].value).toEqual('B');
done(); done();
}, 100); }, 100);
@@ -139,7 +139,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
expect(control.$el.find('input')[0].value).toBe('A'); expect(control.$el.find('input')[0].value).toEqual('A');
done(); done();
}, 100); }, 100);
@@ -162,7 +162,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
expect(control.$el.find('input')[0].value).toBe('A'); expect(control.$el.find('input')[0].value).toEqual('A');
done(); done();
}, 100); }, 100);
@@ -178,7 +178,7 @@ define([
it('when model changes UI should update', function (done) { it('when model changes UI should update', function (done) {
expect(control.$el.find('input')[0].value).toBe('A'); expect(control.$el.find('input')[0].value).toEqual('A');
model.set('key', { model.set('key', {
'key_code': 67, 'key_code': 67,
@@ -187,7 +187,7 @@ define([
// wait until UI updates. // wait until UI updates.
setTimeout(function() { setTimeout(function() {
expect(control.$el.find('input')[0].value).toBe('C'); expect(control.$el.find('input')[0].value).toEqual('C');
done(); done();
}, 100); }, 100);

View File

@@ -96,12 +96,12 @@ describe('BackupDialogWrapper', () => {
return backupNodeChildNodeSpy; return backupNodeChildNodeSpy;
} }
}); });
alertifySpy = jasmine.createSpyObj('alertify', ['alert', 'dialog']);
}); });
describe('#prepare', () => { describe('#prepare', () => {
beforeEach(() => { beforeEach(() => {
alertifySpy = jasmine.createSpyObj('alertify', ['alert', 'dialog']);
backupDialogWrapper = new BackupDialogWrapper( backupDialogWrapper = new BackupDialogWrapper(
'<div class=\'backup_dialog\'></div>', '<div class=\'backup_dialog\'></div>',
'backupDialogTitle', 'backupDialogTitle',
@@ -385,11 +385,11 @@ describe('BackupDialogWrapper', () => {
beforeEach(() => { beforeEach(() => {
pgBrowser.Events = jasmine.createSpyObj('Events', ['trigger']); pgBrowser.Events = jasmine.createSpyObj('Events', ['trigger']);
alertifySpy.success = jasmine.createSpy('success'); alertifySpy.success = jasmine.createSpy('success');
networkMock.onPost('/backup/job/10').reply((request) => { networkMock.onPost('/backup/job/10').reply((request) => {
dataSentToServer = request.data; dataSentToServer = request.data;
return [200, {'success': 1}]; return [200, {'success': 1}];
}); });
}); });
it('creates a success alert box', (done) => { it('creates a success alert box', (done) => {
@@ -436,7 +436,7 @@ describe('BackupDialogWrapper', () => {
}); });
backupDialogWrapper.callback(event); backupDialogWrapper.callback(event);
setTimeout(() => { setTimeout( () => {
expect(alertifySpy.alert).toHaveBeenCalledWith( expect(alertifySpy.alert).toHaveBeenCalledWith(
'Backup job failed.', 'Backup job failed.',
'some-error-message' 'some-error-message'
@@ -550,7 +550,7 @@ describe('BackupDialogWrapper', () => {
}); });
}); });
describe('#setExtraParameters', () => { xdescribe('#setExtraParameters', () => {
let selectedTreeNode; let selectedTreeNode;
let treeInfo; let treeInfo;
let model; let model;

View File

@@ -16,19 +16,19 @@ describe('backup.menuUtils', () => {
describe('#menuEnabledServer', () => { describe('#menuEnabledServer', () => {
context('provided node data is undefined', () => { context('provided node data is undefined', () => {
it('returns false', () => { it('returns false', () => {
expect(menuEnabledServer(undefined)).toBe(false); expect(menuEnabledServer(undefined)).toEqual(false);
}); });
}); });
context('provided node data is null', () => { context('provided node data is null', () => {
it('returns false', () => { it('returns false', () => {
expect(menuEnabledServer(null)).toBe(false); expect(menuEnabledServer(null)).toEqual(false);
}); });
}); });
context('current node type is not of the type server', () => { context('current node type is not of the type server', () => {
it('returns false', () => { it('returns false', () => {
expect(menuEnabledServer({_type: 'schema'})).toBe(false); expect(menuEnabledServer({_type: 'schema'})).toEqual(false);
}); });
}); });
@@ -38,7 +38,7 @@ describe('backup.menuUtils', () => {
expect(menuEnabledServer({ expect(menuEnabledServer({
_type: 'server', _type: 'server',
connected: true, connected: true,
})).toBe(true); })).toEqual(true);
}); });
}); });
context('is not connected', () => { context('is not connected', () => {
@@ -46,7 +46,7 @@ describe('backup.menuUtils', () => {
expect(menuEnabledServer({ expect(menuEnabledServer({
_type: 'server', _type: 'server',
connected: false, connected: false,
})).toBe(false); })).toEqual(false);
}); });
}); });
}); });

View File

@@ -139,7 +139,7 @@ describe('preferences related functions test', function() {
expect($.fn.css).toHaveBeenCalledWith('font-size', '1.46em'); expect($.fn.css).toHaveBeenCalledWith('font-size', '1.46em');
let setOptionCalls = pgBrowser.editor.setOption.calls; let setOptionCalls = pgBrowser.editor.setOption.calls;
expect(setOptionCalls.count()).toBe(Object.keys(editorOptions).length); expect(setOptionCalls.count()).toEqual(Object.keys(editorOptions).length);
for(let i = 0; i < Object.keys(editorOptions).length; i++) { for(let i = 0; i < Object.keys(editorOptions).length; i++) {
let option = Object.keys(editorOptions)[i]; let option = Object.keys(editorOptions)[i];

View File

@@ -36,7 +36,7 @@ describe('when external tables is loaded', () => {
}); });
it('returns the not updated version of pgBrowser', () => { it('returns the not updated version of pgBrowser', () => {
expect(result).toBe(pgBrowser); expect(result).toEqual(pgBrowser);
}); });
}); });

View File

@@ -16,7 +16,7 @@ describe('#show_advanced_tab', () => {
it('should return true', () => { it('should return true', () => {
tableModel = {}; tableModel = {};
expect(show_advanced_tab(tableModel)).toBe(true); expect(show_advanced_tab(tableModel)).toEqual(true);
}); });
}); });
@@ -27,7 +27,7 @@ describe('#show_advanced_tab', () => {
node_info: {}, node_info: {},
}; };
expect(show_advanced_tab(tableModel)).toBe(true); expect(show_advanced_tab(tableModel)).toEqual(true);
}); });
}); });
@@ -42,7 +42,7 @@ describe('#show_advanced_tab', () => {
}, },
}; };
expect(show_advanced_tab(tableModel)).toBe(false); expect(show_advanced_tab(tableModel)).toEqual(false);
}); });
}); });
@@ -56,7 +56,7 @@ describe('#show_advanced_tab', () => {
}, },
}; };
expect(show_advanced_tab(tableModel)).toBe(true); expect(show_advanced_tab(tableModel)).toEqual(true);
}); });
}); });
}); });

View File

@@ -58,7 +58,7 @@ describe('Server#ModelValidation', () => {
describe('Service id present', () => { describe('Service id present', () => {
it('sets empty service name which should throw an error', () => { it('sets empty service name which should throw an error', () => {
model.allValues['service'] = ''; model.allValues['service'] = '';
expect(modelValidation.validate()).toBe('Either Host name, Address or Service must be specified.'); expect(modelValidation.validate()).toEqual('Either Host name, Address or Service must be specified.');
expect(model.errorModel.set).toHaveBeenCalledWith({ expect(model.errorModel.set).toHaveBeenCalledWith({
host: 'Either Host name, Address or Service must be specified.', host: 'Either Host name, Address or Service must be specified.',
hostaddr: 'Either Host name, Address or Service must be specified.', hostaddr: 'Either Host name, Address or Service must be specified.',
@@ -81,7 +81,7 @@ describe('Server#ModelValidation', () => {
it('sets the "SSH Tunnel host must be specified." error', () => { it('sets the "SSH Tunnel host must be specified." error', () => {
model.allValues['tunnel_port'] = 22; model.allValues['tunnel_port'] = 22;
model.allValues['tunnel_username'] = 'user1'; model.allValues['tunnel_username'] = 'user1';
expect(modelValidation.validate()).toBe('SSH Tunnel host must be specified.'); expect(modelValidation.validate()).toEqual('SSH Tunnel host must be specified.');
expect(model.errorModel.set).toHaveBeenCalledWith({ expect(model.errorModel.set).toHaveBeenCalledWith({
tunnel_host:'SSH Tunnel host must be specified.', tunnel_host:'SSH Tunnel host must be specified.',
}); });
@@ -89,7 +89,7 @@ describe('Server#ModelValidation', () => {
it('sets the "SSH Tunnel port must be specified." error', () => { it('sets the "SSH Tunnel port must be specified." error', () => {
model.allValues['tunnel_host'] = 'host'; model.allValues['tunnel_host'] = 'host';
model.allValues['tunnel_username'] = 'user1'; model.allValues['tunnel_username'] = 'user1';
expect(modelValidation.validate()).toBe('SSH Tunnel port must be specified.'); expect(modelValidation.validate()).toEqual('SSH Tunnel port must be specified.');
expect(model.errorModel.set).toHaveBeenCalledWith({ expect(model.errorModel.set).toHaveBeenCalledWith({
tunnel_port:'SSH Tunnel port must be specified.', tunnel_port:'SSH Tunnel port must be specified.',
}); });
@@ -97,7 +97,7 @@ describe('Server#ModelValidation', () => {
it('sets the "SSH Tunnel username be specified." error', () => { it('sets the "SSH Tunnel username be specified." error', () => {
model.allValues['tunnel_host'] = 'host'; model.allValues['tunnel_host'] = 'host';
model.allValues['tunnel_port'] = 22; model.allValues['tunnel_port'] = 22;
expect(modelValidation.validate()).toBe('SSH Tunnel username must be specified.'); expect(modelValidation.validate()).toEqual('SSH Tunnel username must be specified.');
expect(model.errorModel.set).toHaveBeenCalledWith({ expect(model.errorModel.set).toHaveBeenCalledWith({
tunnel_username:'SSH Tunnel username must be specified.', tunnel_username:'SSH Tunnel username must be specified.',
}); });
@@ -107,7 +107,7 @@ describe('Server#ModelValidation', () => {
model.allValues['tunnel_port'] = 22; model.allValues['tunnel_port'] = 22;
model.allValues['tunnel_username'] = 'user1'; model.allValues['tunnel_username'] = 'user1';
model.allValues['tunnel_authentication'] = 1; model.allValues['tunnel_authentication'] = 1;
expect(modelValidation.validate()).toBe('SSH Tunnel identity file must be specified.'); expect(modelValidation.validate()).toEqual('SSH Tunnel identity file must be specified.');
expect(model.errorModel.set).toHaveBeenCalledWith({ expect(model.errorModel.set).toHaveBeenCalledWith({
tunnel_identity_file:'SSH Tunnel identity file must be specified.', tunnel_identity_file:'SSH Tunnel identity file must be specified.',
}); });
@@ -118,7 +118,7 @@ describe('Server#ModelValidation', () => {
describe('When no parameters are valid', () => { describe('When no parameters are valid', () => {
describe('Service id not present', () => { describe('Service id not present', () => {
it('does not set any error in the model', () => { it('does not set any error in the model', () => {
expect(modelValidation.validate()).toBe('Name must be specified.'); expect(modelValidation.validate()).toEqual('Name must be specified.');
expect(model.errorModel.set).toHaveBeenCalledTimes(1); expect(model.errorModel.set).toHaveBeenCalledTimes(1);
expect(model.errorModel.set).toHaveBeenCalledWith({ expect(model.errorModel.set).toHaveBeenCalledWith({
name: 'Name must be specified.', name: 'Name must be specified.',
@@ -134,7 +134,7 @@ describe('Server#ModelValidation', () => {
describe('Host address is not valid', () => { describe('Host address is not valid', () => {
it('sets the "Host address must be a valid IPv4 or IPv6 address" error', () => { it('sets the "Host address must be a valid IPv4 or IPv6 address" error', () => {
model.allValues['hostaddr'] = 'something that is not an ip address'; model.allValues['hostaddr'] = 'something that is not an ip address';
expect(modelValidation.validate()).toBe('Host address must be valid IPv4 or IPv6 address.'); expect(modelValidation.validate()).toEqual('Host address must be valid IPv4 or IPv6 address.');
expect(model.errorModel.set).toHaveBeenCalledTimes(1); expect(model.errorModel.set).toHaveBeenCalledTimes(1);
expect(model.errorModel.set).toHaveBeenCalledWith({ expect(model.errorModel.set).toHaveBeenCalledWith({
name: 'Name must be specified.', name: 'Name must be specified.',
@@ -149,7 +149,7 @@ describe('Server#ModelValidation', () => {
describe('Service id present', () => { describe('Service id present', () => {
it('does not set any error in the model', () => { it('does not set any error in the model', () => {
model.allValues['service'] = 'asdfg'; model.allValues['service'] = 'asdfg';
expect(modelValidation.validate()).toBe('Name must be specified.'); expect(modelValidation.validate()).toEqual('Name must be specified.');
expect(model.errorModel.set).toHaveBeenCalledTimes(1); expect(model.errorModel.set).toHaveBeenCalledTimes(1);
expect(model.errorModel.set).toHaveBeenCalledWith({ expect(model.errorModel.set).toHaveBeenCalledWith({
name: 'Name must be specified.', name: 'Name must be specified.',

View File

@@ -8,7 +8,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
define(['sources/check_node_visibility'], define(['sources/check_node_visibility'],
function (checkNodeVisibility) { function (checkNodeVisibility) {
describe('checkNodeVisibility', function () { describe('checkNodeVisibility', function () {
var browser; var browser;
@@ -29,4 +29,4 @@ function (checkNodeVisibility) {
}); });
}); });
}); });
}); });

View File

@@ -7,7 +7,7 @@
// //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
import keyboardShortcuts from 'sources/keyboard_shortcuts'; import * as keyboardShortcuts from 'sources/keyboard_shortcuts';
describe('the keyboard shortcuts', () => { describe('the keyboard shortcuts', () => {
const F1_KEY = 112; const F1_KEY = 112;

View File

@@ -28,7 +28,7 @@ describe('In charting related testcases', ()=> {
}); });
it('Return the correct container', ()=>{ it('Return the correct container', ()=>{
expect(chartObj.getContainer()).toBe(chartDiv); expect(chartObj.getContainer()).toEqual(chartDiv);
}); });
it('Returns the container dimensions', ()=>{ it('Returns the container dimensions', ()=>{
@@ -74,7 +74,7 @@ describe('In charting related testcases', ()=> {
}); });
it('Check if other data returns undefined for not set', ()=>{ it('Check if other data returns undefined for not set', ()=>{
expect(chartObj.getOtherData('some_val_not_set')).toBe(undefined); expect(chartObj.getOtherData('some_val_not_set')).toEqual(undefined);
}); });
it('Check if isVisible returns correct', ()=>{ it('Check if isVisible returns correct', ()=>{
@@ -83,19 +83,19 @@ describe('In charting related testcases', ()=> {
dimSpy.and.returnValue({ dimSpy.and.returnValue({
height: 1, width: 1, height: 1, width: 1,
}); });
expect(chartObj.isVisible()).toBe(true); expect(chartObj.isVisible()).toEqual(true);
dimSpy.and.stub(); dimSpy.and.stub();
dimSpy.and.returnValue({ dimSpy.and.returnValue({
height: 0, width: 0, height: 0, width: 0,
}); });
expect(chartObj.isVisible()).toBe(false); expect(chartObj.isVisible()).toEqual(false);
}); });
it('Check if isInPage returns correct', ()=>{ it('Check if isInPage returns correct', ()=>{
expect(chartObj.isInPage()).toBe(true); expect(chartObj.isInPage()).toEqual(true);
$('body').find('#charting-test-container').remove(); $('body').find('#charting-test-container').remove();
expect(chartObj.isInPage()).toBe(false); expect(chartObj.isInPage()).toEqual(false);
}); });
afterEach(()=>{ afterEach(()=>{

View File

@@ -54,7 +54,7 @@ describe('#getPanelTitle', () => {
tree.selectNode([{id: 'level1'}]); tree.selectNode([{id: 'level1'}]);
expect(getPanelTitle(pgBrowser)) expect(getPanelTitle(pgBrowser))
.toBe('other db label/some user name@server label'); .toEqual('other db label/some user name@server label');
}); });
}); });
@@ -75,7 +75,7 @@ describe('#getPanelTitle', () => {
new TreeNode('level1.1.1', {_type: 'table'})); new TreeNode('level1.1.1', {_type: 'table'}));
tree.selectNode([{id: 'level1.1.1'}]); tree.selectNode([{id: 'level1.1.1'}]);
expect(getPanelTitle(pgBrowser)) expect(getPanelTitle(pgBrowser))
.toBe('db label/some user name@server label'); .toEqual('db label/some user name@server label');
}); });
}); });
}); });

View File

@@ -66,19 +66,19 @@ describe('getProcedureId', function () {
describe('Should return proper object id', function () { describe('Should return proper object id', function () {
it('returns valid procedure id', function () { it('returns valid procedure id', function () {
expect(getProcedureId(treeInfroProc)).toBe(123); expect(getProcedureId(treeInfroProc)).toEqual(123);
}); });
it('returns valid edbproc id', function () { it('returns valid edbproc id', function () {
expect(getProcedureId(treeInfroEdbProc)).toBe(321); expect(getProcedureId(treeInfroEdbProc)).toEqual(321);
}); });
it('returns undefined for fake tree info', function () { it('returns undefined for fake tree info', function () {
expect(getProcedureId(fakeTreeInfro)).toBe(undefined); expect(getProcedureId(fakeTreeInfro)).toEqual(undefined);
}); });
it('returns undefined for invalid procedure id', function () { it('returns undefined for invalid procedure id', function () {
expect(getProcedureId(treeInfroInvalidProcId)).toBe(undefined); expect(getProcedureId(treeInfroInvalidProcId)).toEqual(undefined);
}); });
}); });
}); });

View File

@@ -55,7 +55,7 @@ describe('geometry viewer test', function () {
]; ];
let columnIndex = 0; let columnIndex = 0;
let result = GeometryViewer.parse_data(items, columns, columnIndex); let result = GeometryViewer.parse_data(items, columns, columnIndex);
expect(result.geoJSONs.length).toBe(2); expect(result.geoJSONs.length).toEqual(2);
}); });
@@ -76,7 +76,7 @@ describe('geometry viewer test', function () {
]; ];
let columnIndex = 0; let columnIndex = 0;
let result = GeometryViewer.parse_data(items, columns, columnIndex); let result = GeometryViewer.parse_data(items, columns, columnIndex);
expect(result.geoJSONs.length).toBe(1); expect(result.geoJSONs.length).toEqual(1);
}); });
it('should support geometry M', function () { it('should support geometry M', function () {
@@ -96,7 +96,7 @@ describe('geometry viewer test', function () {
]; ];
let columnIndex = 0; let columnIndex = 0;
let result = GeometryViewer.parse_data(items, columns, columnIndex); let result = GeometryViewer.parse_data(items, columns, columnIndex);
expect(result.geoJSONs.length).toBe(1); expect(result.geoJSONs.length).toEqual(1);
}); });
it('should support empty geometry', function () { it('should support empty geometry', function () {
@@ -114,7 +114,7 @@ describe('geometry viewer test', function () {
]; ];
let columnIndex = 0; let columnIndex = 0;
let result = GeometryViewer.parse_data(items, columns, columnIndex); let result = GeometryViewer.parse_data(items, columns, columnIndex);
expect(result.geoJSONs.length).toBe(1); expect(result.geoJSONs.length).toEqual(1);
}); });
@@ -145,7 +145,7 @@ describe('geometry viewer test', function () {
]; ];
let columnIndex = 0; let columnIndex = 0;
let result = GeometryViewer.parse_data(items, columns, columnIndex); let result = GeometryViewer.parse_data(items, columns, columnIndex);
expect(result.geoJSONs.length).toBe(2); expect(result.geoJSONs.length).toEqual(2);
}); });
@@ -164,7 +164,7 @@ describe('geometry viewer test', function () {
]; ];
let columnIndex = 0; let columnIndex = 0;
let result = GeometryViewer.parse_data(items, columns, columnIndex); let result = GeometryViewer.parse_data(items, columns, columnIndex);
expect(result.geoJSONs.length).toBe(0); expect(result.geoJSONs.length).toEqual(0);
}); });
it('should not support 3DM geometry', function () { it('should not support 3DM geometry', function () {
@@ -183,7 +183,7 @@ describe('geometry viewer test', function () {
]; ];
let columnIndex = 0; let columnIndex = 0;
let result = GeometryViewer.parse_data(items, columns, columnIndex); let result = GeometryViewer.parse_data(items, columns, columnIndex);
expect(result.geoJSONs.length).toBe(0); expect(result.geoJSONs.length).toEqual(0);
}); });
it('should not support TRIANGLE geometry', function () { it('should not support TRIANGLE geometry', function () {
@@ -203,7 +203,7 @@ describe('geometry viewer test', function () {
]; ];
let columnIndex = 0; let columnIndex = 0;
let result = GeometryViewer.parse_data(items, columns, columnIndex); let result = GeometryViewer.parse_data(items, columns, columnIndex);
expect(result.geoJSONs.length).toBe(0); expect(result.geoJSONs.length).toEqual(0);
}); });
it('should limit data size', function () { it('should limit data size', function () {

View File

@@ -25,11 +25,11 @@ describe('historyCollection', function () {
it('returns 0 when underlying history model has no elements', function () { it('returns 0 when underlying history model has no elements', function () {
historyCollection = new HistoryCollection([]); historyCollection = new HistoryCollection([]);
expect(historyCollection.length()).toBe(0); expect(historyCollection.length()).toEqual(0);
}); });
it('returns the length of the underlying history model', function () { it('returns the length of the underlying history model', function () {
expect(historyCollection.length()).toBe(1); expect(historyCollection.length()).toEqual(1);
}); });
}); });
@@ -61,7 +61,7 @@ describe('historyCollection', function () {
it('drops the history', function () { it('drops the history', function () {
expect(historyCollection.historyList).toEqual([]); expect(historyCollection.historyList).toEqual([]);
expect(historyCollection.length()).toBe(0); expect(historyCollection.length()).toEqual(0);
}); });
it('calls the onReset function', function () { it('calls the onReset function', function () {

View File

@@ -32,7 +32,7 @@ describe('ExplainStatistics', () => {
statsModel.set('Triggers', []); statsModel.set('Triggers', []);
statsModel.set_statistics(tooltipContainer); statsModel.set_statistics(tooltipContainer);
expect($('.pg-explain-stats-area').hasClass('d-none')).toBe(true); expect($('.pg-explain-stats-area').hasClass('d-none')).toEqual(true);
}); });
}); });
@@ -45,7 +45,7 @@ describe('ExplainStatistics', () => {
}); });
it('Statistics button should be visible', () => { it('Statistics button should be visible', () => {
expect($('.pg-explain-stats-area').hasClass('d-none')).toBe(false); expect($('.pg-explain-stats-area').hasClass('d-none')).toEqual(false);
}); });
it('Mouse over event should be trigger', () => { it('Mouse over event should be trigger', () => {
@@ -53,7 +53,7 @@ describe('ExplainStatistics', () => {
var hoverEvent = new $.Event('mouseover'); var hoverEvent = new $.Event('mouseover');
$('.pg-explain-stats-area').trigger(hoverEvent); $('.pg-explain-stats-area').trigger(hoverEvent);
expect(tooltipContainer.css('opacity')).toBe('0.8'); expect(tooltipContainer.css('opacity')).toEqual('0.8');
}); });
it('Mouse out event should be trigger', () => { it('Mouse out event should be trigger', () => {
@@ -61,7 +61,7 @@ describe('ExplainStatistics', () => {
var hoverEvent = new $.Event('mouseout'); var hoverEvent = new $.Event('mouseout');
$('.pg-explain-stats-area').trigger(hoverEvent); $('.pg-explain-stats-area').trigger(hoverEvent);
expect(tooltipContainer.css('opacity')).toBe('0'); expect(tooltipContainer.css('opacity')).toEqual('0');
}); });
}); });
@@ -74,7 +74,7 @@ describe('ExplainStatistics', () => {
}); });
it('Statistics button should be visible', () => { it('Statistics button should be visible', () => {
expect($('.pg-explain-stats-area').hasClass('d-none')).toBe(false); expect($('.pg-explain-stats-area').hasClass('d-none')).toEqual(false);
}); });
it('Mouse over event should be trigger', () => { it('Mouse over event should be trigger', () => {
@@ -82,7 +82,7 @@ describe('ExplainStatistics', () => {
var hoverEvent = new $.Event('mouseover'); var hoverEvent = new $.Event('mouseover');
$('.pg-explain-stats-area').trigger(hoverEvent); $('.pg-explain-stats-area').trigger(hoverEvent);
expect(tooltipContainer.css('opacity')).toBe('0.8'); expect(tooltipContainer.css('opacity')).toEqual('0.8');
}); });
it('Mouse out event should be trigger', () => { it('Mouse out event should be trigger', () => {
@@ -90,7 +90,7 @@ describe('ExplainStatistics', () => {
var hoverEvent = new $.Event('mouseout'); var hoverEvent = new $.Event('mouseout');
$('.pg-explain-stats-area').trigger(hoverEvent); $('.pg-explain-stats-area').trigger(hoverEvent);
expect(tooltipContainer.css('opacity')).toBe('0'); expect(tooltipContainer.css('opacity')).toEqual('0');
}); });
}); });
}); });

View File

@@ -15,7 +15,7 @@ describe('#nodeHasStatistics', () => {
const node = { const node = {
hasStatistics: true, hasStatistics: true,
}; };
expect(nodeHasStatistics(node, {})).toBe(true); expect(nodeHasStatistics(node, {})).toEqual(true);
}); });
}); });
@@ -28,7 +28,7 @@ describe('#nodeHasStatistics', () => {
}; };
const item = {}; const item = {};
expect(nodeHasStatistics(node, item)).toBe(true); expect(nodeHasStatistics(node, item)).toEqual(true);
expect(node.getTreeNodeHierarchy).toHaveBeenCalledWith(item); expect(node.getTreeNodeHierarchy).toHaveBeenCalledWith(item);
}); });
}); });

View File

@@ -115,7 +115,7 @@ describe('RestoreDialogWrapper', () => {
it('disables the button "submit button" until a filename is selected', () => { it('disables the button "submit button" until a filename is selected', () => {
restoreDialogWrapper.prepare(); restoreDialogWrapper.prepare();
expect(restoreDialogWrapper.__internal.buttons[3].element.disabled).toBe(true); expect(restoreDialogWrapper.__internal.buttons[3].element.disabled).toEqual(true);
}); });
}); });
@@ -131,7 +131,7 @@ describe('RestoreDialogWrapper', () => {
it('disables the button "submit button" until a filename is selected', () => { it('disables the button "submit button" until a filename is selected', () => {
restoreDialogWrapper.prepare(); restoreDialogWrapper.prepare();
expect(restoreDialogWrapper.__internal.buttons[3].element.disabled).toBe(true); expect(restoreDialogWrapper.__internal.buttons[3].element.disabled).toEqual(true);
}); });
}); });
@@ -177,7 +177,7 @@ describe('RestoreDialogWrapper', () => {
it('disables the button submit button until a filename is selected', () => { it('disables the button submit button until a filename is selected', () => {
restoreDialogWrapper.prepare(); restoreDialogWrapper.prepare();
expect(restoreNode.__internal.buttons[3].element.disabled).toBe(true); expect(restoreNode.__internal.buttons[3].element.disabled).toEqual(true);
}); });
it('generates a new restore model', () => { it('generates a new restore model', () => {
@@ -257,7 +257,7 @@ describe('RestoreDialogWrapper', () => {
}); });
it('does not start the restore', () => { it('does not start the restore', () => {
expect(networkCalled).toBe(false); expect(networkCalled).toEqual(false);
}); });
}); });
@@ -298,7 +298,7 @@ describe('RestoreDialogWrapper', () => {
}); });
it('does not start the restore', () => { it('does not start the restore', () => {
expect(networkCalled).toBe(false); expect(networkCalled).toEqual(false);
}); });
}); });
@@ -327,7 +327,7 @@ describe('RestoreDialogWrapper', () => {
it('does not start the restore', () => { it('does not start the restore', () => {
restoreDialogWrapper.callback(event); restoreDialogWrapper.callback(event);
expect(networkCalled).toBe(false); expect(networkCalled).toEqual(false);
}); });
}); });
@@ -353,7 +353,7 @@ describe('RestoreDialogWrapper', () => {
it('does not start the restore', () => { it('does not start the restore', () => {
restoreDialogWrapper.callback(event); restoreDialogWrapper.callback(event);
expect(networkCalled).toBe(false); expect(networkCalled).toEqual(false);
}); });
}); });

View File

@@ -100,7 +100,7 @@ describe('ColumnSelector', function () {
var columnSelector = new ColumnSelector(); var columnSelector = new ColumnSelector();
var selectableColumns = columnSelector.getColumnDefinitions(columns); var selectableColumns = columnSelector.getColumnDefinitions(columns);
expect(selectableColumns[1].id).toBe('1'); expect(selectableColumns[1].id).toEqual('1');
}); });
describe('with ActiveCellCapture, CellSelectionModel, and GridSelector: selecting columns', function () { describe('with ActiveCellCapture, CellSelectionModel, and GridSelector: selecting columns', function () {
@@ -142,11 +142,11 @@ describe('ColumnSelector', function () {
it('toggles a selected class to the header cell', function () { it('toggles a selected class to the header cell', function () {
container.find('.slick-header-column:contains(second column)').click(); container.find('.slick-header-column:contains(second column)').click();
expect($(container.find('.slick-header-column:contains(second column)')).hasClass('selected')) expect($(container.find('.slick-header-column:contains(second column)')).hasClass('selected'))
.toBe(true); .toEqual(true);
container.find('.slick-header-column:contains(second column)').click(); container.find('.slick-header-column:contains(second column)').click();
expect($(container.find('.slick-header-column:contains(second column)')).hasClass('selected')) expect($(container.find('.slick-header-column:contains(second column)')).hasClass('selected'))
.toBe(false); .toEqual(false);
}); });
}); });
@@ -160,14 +160,14 @@ describe('ColumnSelector', function () {
var selectedRanges = cellSelectionModel.getSelectedRanges(); var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(2); expect(selectedRanges.length).toEqual(2);
var column1 = selectedRanges[0]; var column1 = selectedRanges[0];
expect(column1.fromCell).toBe(1); expect(column1.fromCell).toEqual(1);
expect(column1.toCell).toBe(1); expect(column1.toCell).toEqual(1);
var column2 = selectedRanges[1]; var column2 = selectedRanges[1];
expect(column2.fromCell).toBe(2); expect(column2.fromCell).toEqual(2);
expect(column2.toCell).toBe(2); expect(column2.toCell).toEqual(2);
}); });
describe('and presses shift + right-arrow', function () { describe('and presses shift + right-arrow', function () {
@@ -176,24 +176,24 @@ describe('ColumnSelector', function () {
}); });
it('keeps the last column selected', function () { it('keeps the last column selected', function () {
expect(cellSelectionModel.getSelectedRanges().length).toBe(1); expect(cellSelectionModel.getSelectedRanges().length).toEqual(1);
}); });
it('grows the selection to the right', function () { it('grows the selection to the right', function () {
var selectedRange = cellSelectionModel.getSelectedRanges()[0]; var selectedRange = cellSelectionModel.getSelectedRanges()[0];
expect(selectedRange.fromCell).toBe(2); expect(selectedRange.fromCell).toEqual(2);
expect(selectedRange.toCell).toBe(3); expect(selectedRange.toCell).toEqual(3);
expect(selectedRange.fromRow).toBe(0); expect(selectedRange.fromRow).toEqual(0);
expect(selectedRange.toRow).toBe(9); expect(selectedRange.toRow).toEqual(9);
}); });
it('keeps selected class on columns 2 and 3', function () { it('keeps selected class on columns 2 and 3', function () {
expect($(container.find('.slick-header-column:contains(second column)')).hasClass('selected')) expect($(container.find('.slick-header-column:contains(second column)')).hasClass('selected'))
.toBe(true); .toEqual(true);
expect($(container.find('.slick-header-column:contains(third column)')).hasClass('selected')) expect($(container.find('.slick-header-column:contains(third column)')).hasClass('selected'))
.toBe(true); .toEqual(true);
expect($(container.find('.slick-header-column:contains(some-column-name)')).hasClass('selected')) expect($(container.find('.slick-header-column:contains(some-column-name)')).hasClass('selected'))
.toBe(false); .toEqual(false);
}); });
}); });
@@ -208,11 +208,11 @@ describe('ColumnSelector', function () {
var selectedRanges = cellSelectionModel.getSelectedRanges(); var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
expect(selectedRanges[0].fromCell).toBe(1); expect(selectedRanges[0].fromCell).toEqual(1);
expect(selectedRanges[0].toCell).toBe(2); expect(selectedRanges[0].toCell).toEqual(2);
expect(selectedRanges[0].fromRow).toBe(0); expect(selectedRanges[0].fromRow).toEqual(0);
expect(selectedRanges[0].toRow).toBe(9); expect(selectedRanges[0].toRow).toEqual(9);
}); });
}); });
}); });
@@ -229,11 +229,11 @@ describe('ColumnSelector', function () {
it('toggles a selected class to the header cell', function () { it('toggles a selected class to the header cell', function () {
container.find('.slick-header-column span.column-description:contains(second column)').click(); container.find('.slick-header-column span.column-description:contains(second column)').click();
expect($(container.find('.slick-header-column:contains(second column)')).hasClass('selected')) expect($(container.find('.slick-header-column:contains(second column)')).hasClass('selected'))
.toBe(true); .toEqual(true);
container.find('.slick-header-column span.column-description:contains(second column)').click(); container.find('.slick-header-column span.column-description:contains(second column)').click();
expect($(container.find('.slick-header-column:contains(second column)')).hasClass('selected')) expect($(container.find('.slick-header-column:contains(second column)')).hasClass('selected'))
.toBe(false); .toEqual(false);
}); });
}); });
@@ -247,14 +247,14 @@ describe('ColumnSelector', function () {
container.find('.slick-header-column')[1].click(); container.find('.slick-header-column')[1].click();
var selectedRanges = cellSelectionModel.getSelectedRanges(); var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
var column = selectedRanges[0]; var column = selectedRanges[0];
expect(column.fromCell).toBe(1); expect(column.fromCell).toEqual(1);
expect(column.toCell).toBe(1); expect(column.toCell).toEqual(1);
expect(column.fromRow).toBe(0); expect(column.fromRow).toEqual(0);
expect(column.toRow).toBe(9); expect(column.toRow).toEqual(9);
}); });
}); });
@@ -289,7 +289,7 @@ describe('ColumnSelector', function () {
cellSelectionModel.setSelectedRanges([]); cellSelectionModel.setSelectedRanges([]);
expect($(container.find('.slick-header-column')[1]).hasClass('selected')) expect($(container.find('.slick-header-column')[1]).hasClass('selected'))
.toBe(false); .toEqual(false);
}); });
}); });
@@ -321,14 +321,14 @@ describe('ColumnSelector', function () {
var selectedRanges = cellSelectionModel.getSelectedRanges(); var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
var column = selectedRanges[0]; var column = selectedRanges[0];
expect(column.fromCell).toBe(1); expect(column.fromCell).toEqual(1);
expect(column.toCell).toBe(1); expect(column.toCell).toEqual(1);
expect(column.fromRow).toBe(1); expect(column.fromRow).toEqual(1);
expect(column.toRow).toBe(1); expect(column.toRow).toEqual(1);
}); });
it('keep select class on column header', function () { it('keep select class on column header', function () {
@@ -346,14 +346,14 @@ describe('ColumnSelector', function () {
var selectedRanges = cellSelectionModel.getSelectedRanges(); var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
var column = selectedRanges[0]; var column = selectedRanges[0];
expect(column.fromCell).toBe(2); expect(column.fromCell).toEqual(2);
expect(column.toCell).toBe(2); expect(column.toCell).toEqual(2);
expect(column.fromRow).toBe(2); expect(column.fromRow).toEqual(2);
expect(column.toRow).toBe(2); expect(column.toRow).toEqual(2);
}); });
it('remove select class on \'some-column-name\' column header', function () { it('remove select class on \'some-column-name\' column header', function () {
@@ -373,14 +373,14 @@ describe('ColumnSelector', function () {
it('column is deselected', function () { it('column is deselected', function () {
var selectedRanges = cellSelectionModel.getSelectedRanges(); var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
var column = selectedRanges[0]; var column = selectedRanges[0];
expect(column.fromCell).toBe(1); expect(column.fromCell).toEqual(1);
expect(column.toCell).toBe(3); expect(column.toCell).toEqual(3);
expect(column.fromRow).toBe(1); expect(column.fromRow).toEqual(1);
expect(column.toRow).toBe(1); expect(column.toRow).toEqual(1);
}); });
it('no column should have the class \'selected\'', function () { it('no column should have the class \'selected\'', function () {
@@ -407,10 +407,10 @@ describe('ColumnSelector', function () {
var row = selectedRanges[0]; var row = selectedRanges[0];
expect(selectedRanges.length).toEqual(1); expect(selectedRanges.length).toEqual(1);
expect(row.fromCell).toBe(1); expect(row.fromCell).toEqual(1);
expect(row.toCell).toBe(1); expect(row.toCell).toEqual(1);
expect(row.fromRow).toBe(0); expect(row.fromRow).toEqual(0);
expect(row.toRow).toBe(9); expect(row.toRow).toEqual(9);
} }
function pressShiftArrow(keyCode) { function pressShiftArrow(keyCode) {

View File

@@ -88,11 +88,11 @@ describe('copyData', function () {
}); });
it('copies them', function () { it('copies them', function () {
spyOn(clipboard, 'copyTextToClipboard'); spyOn(clipboard, 'copyTextToClipboard').and.callThrough();
copyData.apply(sqlEditor); copyData.apply(sqlEditor);
expect(sqlEditor.copied_rows.length).toBe(2); expect(sqlEditor.copied_rows.length).toEqual(2);
expect(clipboard.copyTextToClipboard).toHaveBeenCalled(); expect(clipboard.copyTextToClipboard).toHaveBeenCalled();
expect(clipboard.copyTextToClipboard.calls.mostRecent().args[0]).toContain('1,"leopord",12'); expect(clipboard.copyTextToClipboard.calls.mostRecent().args[0]).toContain('1,"leopord",12');
@@ -103,7 +103,7 @@ describe('copyData', function () {
it('enables the paste row button', function () { it('enables the paste row button', function () {
copyData.apply(_.extend({can_edit: true}, sqlEditor)); copyData.apply(_.extend({can_edit: true}, sqlEditor));
expect($('#btn-paste-row').prop('disabled')).toBe(false); expect($('#btn-paste-row').prop('disabled')).toEqual(false);
}); });
}); });
}); });
@@ -123,15 +123,15 @@ describe('copyData', function () {
var copyArg = clipboard.copyTextToClipboard.calls.mostRecent().args[0]; var copyArg = clipboard.copyTextToClipboard.calls.mostRecent().args[0];
var rowStrings = copyArg.split('\n'); var rowStrings = copyArg.split('\n');
expect(rowStrings[0]).toBe('1'); expect(rowStrings[0]).toEqual('1');
expect(rowStrings[1]).toBe('2'); expect(rowStrings[1]).toEqual('2');
expect(rowStrings[2]).toBe('3'); expect(rowStrings[2]).toEqual('3');
}); });
it('sets copied_rows to empty', function () { it('sets copied_rows to empty', function () {
copyData.apply(sqlEditor); copyData.apply(sqlEditor);
expect(sqlEditor.copied_rows.length).toBe(0); expect(sqlEditor.copied_rows.length).toEqual(0);
}); });
describe('when the user can edit the grid', function () { describe('when the user can edit the grid', function () {
@@ -140,7 +140,7 @@ describe('copyData', function () {
}); });
it('disables the paste row button', function () { it('disables the paste row button', function () {
expect($('#btn-paste-row').prop('disabled')).toBe(true); expect($('#btn-paste-row').prop('disabled')).toEqual(true);
}); });
}); });
}); });

View File

@@ -56,14 +56,14 @@ describe('GridSelector', function () {
}); });
it('renders an additional column on the left for selecting rows', function () { it('renders an additional column on the left for selecting rows', function () {
expect(columns.length).toBe(3); expect(columns.length).toEqual(3);
var leftmostColumn = columns[0]; var leftmostColumn = columns[0];
expect(leftmostColumn.id).toBe('row-header-column'); expect(leftmostColumn.id).toEqual('row-header-column');
}); });
it('renders a button for selecting all the cells', function () { it('renders a button for selecting all the cells', function () {
expect(container.find('[title=\'Select/Deselect All\']').length).toBe(1); expect(container.find('[title=\'Select/Deselect All\']').length).toEqual(1);
}); });
describe('when the cell for the select/deselect all is clicked', function () { describe('when the cell for the select/deselect all is clicked', function () {
@@ -71,12 +71,12 @@ describe('GridSelector', function () {
container.find('[title=\'Select/Deselect All\']').parent().trigger('click'); container.find('[title=\'Select/Deselect All\']').parent().trigger('click');
var selectedRanges = xCellSelectionModel.getSelectedRanges(); var selectedRanges = xCellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
var selectedRange = selectedRanges[0]; var selectedRange = selectedRanges[0];
expect(selectedRange.fromCell).toBe(1); expect(selectedRange.fromCell).toEqual(1);
expect(selectedRange.toCell).toBe(2); expect(selectedRange.toCell).toEqual(2);
expect(selectedRange.fromRow).toBe(0); expect(selectedRange.fromRow).toEqual(0);
expect(selectedRange.toRow).toBe(9); expect(selectedRange.toRow).toEqual(9);
}); });
it('adds selected class', function () { it('adds selected class', function () {
@@ -92,12 +92,12 @@ describe('GridSelector', function () {
container.find('[title=\'Select/Deselect All\']').trigger('click'); container.find('[title=\'Select/Deselect All\']').trigger('click');
var selectedRanges = xCellSelectionModel.getSelectedRanges(); var selectedRanges = xCellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
var selectedRange = selectedRanges[0]; var selectedRange = selectedRanges[0];
expect(selectedRange.fromCell).toBe(1); expect(selectedRange.fromCell).toEqual(1);
expect(selectedRange.toCell).toBe(2); expect(selectedRange.toCell).toEqual(2);
expect(selectedRange.fromRow).toBe(0); expect(selectedRange.fromRow).toEqual(0);
expect(selectedRange.toRow).toBe(9); expect(selectedRange.toRow).toEqual(9);
}); });
describe('when the select all button in the corner gets deselected', function () { describe('when the select all button in the corner gets deselected', function () {
@@ -109,7 +109,7 @@ describe('GridSelector', function () {
container.find('[title=\'Select/Deselect All\']').trigger('click'); container.find('[title=\'Select/Deselect All\']').trigger('click');
var selectedRanges = xCellSelectionModel.getSelectedRanges(); var selectedRanges = xCellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(0); expect(selectedRanges.length).toEqual(0);
}); });
}); });

View File

@@ -66,22 +66,22 @@ describe('RowSelector', function () {
}); });
it('renders an additional column on the left', function () { it('renders an additional column on the left', function () {
expect(columnDefinitions.length).toBe(3); expect(columnDefinitions.length).toEqual(3);
var leftmostColumn = columnDefinitions[0]; var leftmostColumn = columnDefinitions[0];
expect(leftmostColumn.id).toBe('row-header-column'); expect(leftmostColumn.id).toEqual('row-header-column');
expect(leftmostColumn.name).toBe(''); expect(leftmostColumn.name).toEqual('');
expect(leftmostColumn.selectable).toBe(false); expect(leftmostColumn.selectable).toEqual(false);
}); });
it('renders a span on the leftmost column', function () { it('renders a span on the leftmost column', function () {
expect(container.find('.slick-row').length).toBe(10); expect(container.find('.slick-row').length).toEqual(10);
expect(container.find('.slick-row .slick-cell:first-child span[data-cell-type="row-header-selector"]').length).toBe(10); expect(container.find('.slick-row .slick-cell:first-child span[data-cell-type="row-header-selector"]').length).toEqual(10);
}); });
it('preserves the other attributes of column definitions', function () { it('preserves the other attributes of column definitions', function () {
expect(columnDefinitions[1].id).toBe('1'); expect(columnDefinitions[1].id).toEqual('1');
expect(columnDefinitions[1].selectable).toBe(true); expect(columnDefinitions[1].selectable).toEqual(true);
}); });
describe('selecting rows', function () { describe('selecting rows', function () {
@@ -112,10 +112,10 @@ describe('RowSelector', function () {
var row = selectedRanges[0]; var row = selectedRanges[0];
expect(selectedRanges.length).toEqual(1); expect(selectedRanges.length).toEqual(1);
expect(row.fromCell).toBe(1); expect(row.fromCell).toEqual(1);
expect(row.toCell).toBe(2); expect(row.toCell).toEqual(2);
expect(row.fromRow).toBe(1); expect(row.fromRow).toEqual(1);
expect(row.toRow).toBe(1); expect(row.toRow).toEqual(1);
}); });
it('add selected class to parent of the span', function () { it('add selected class to parent of the span', function () {
@@ -139,7 +139,7 @@ describe('RowSelector', function () {
}); });
it('keeps the last row selected', function () { it('keeps the last row selected', function () {
expect(cellSelectionModel.getSelectedRanges().length).toBe(1); expect(cellSelectionModel.getSelectedRanges().length).toEqual(1);
}); });
it('grows the selection down', function () { it('grows the selection down', function () {
@@ -148,10 +148,10 @@ describe('RowSelector', function () {
var row = selectedRanges[0]; var row = selectedRanges[0];
expect(selectedRanges.length).toEqual(1); expect(selectedRanges.length).toEqual(1);
expect(row.fromCell).toBe(1); expect(row.fromCell).toEqual(1);
expect(row.toCell).toBe(2); expect(row.toCell).toEqual(2);
expect(row.fromRow).toBe(1); expect(row.fromRow).toEqual(1);
expect(row.toRow).toBe(2); expect(row.toRow).toEqual(2);
}); });
it('keeps selected class on rows 1 and 2', function () { it('keeps selected class on rows 1 and 2', function () {
@@ -175,14 +175,14 @@ describe('RowSelector', function () {
var selectedRanges = cellSelectionModel.getSelectedRanges(); var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
var newSelection = selectedRanges[0]; var newSelection = selectedRanges[0];
expect(newSelection.fromCell).toBe(1); expect(newSelection.fromCell).toEqual(1);
expect(newSelection.fromRow).toBe(5); expect(newSelection.fromRow).toEqual(5);
expect(newSelection.toCell).toBe(1); expect(newSelection.toCell).toEqual(1);
expect(newSelection.toRow).toBe(5); expect(newSelection.toRow).toEqual(5);
}); });
it('keep select class on row header', function () { it('keep select class on row header', function () {
@@ -200,14 +200,14 @@ describe('RowSelector', function () {
var selectedRanges = cellSelectionModel.getSelectedRanges(); var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
var newSelection = selectedRanges[0]; var newSelection = selectedRanges[0];
expect(newSelection.fromCell).toBe(2); expect(newSelection.fromCell).toEqual(2);
expect(newSelection.fromRow).toBe(2); expect(newSelection.fromRow).toEqual(2);
expect(newSelection.toCell).toBe(2); expect(newSelection.toCell).toEqual(2);
expect(newSelection.toRow).toBe(2); expect(newSelection.toRow).toEqual(2);
}); });
it('remove select class on "some-column-name" column header', function () { it('remove select class on "some-column-name" column header', function () {
@@ -250,12 +250,12 @@ describe('RowSelector', function () {
expect(selectedRanges.length).toEqual(2); expect(selectedRanges.length).toEqual(2);
var row1 = selectedRanges[0]; var row1 = selectedRanges[0];
expect(row1.fromRow).toBe(4); expect(row1.fromRow).toEqual(4);
expect(row1.toRow).toBe(4); expect(row1.toRow).toEqual(4);
var row2 = selectedRanges[1]; var row2 = selectedRanges[1];
expect(row2.fromRow).toBe(0); expect(row2.fromRow).toEqual(0);
expect(row2.toRow).toBe(0); expect(row2.toRow).toEqual(0);
}); });
}); });
@@ -320,9 +320,9 @@ describe('RowSelector', function () {
var row = selectedRanges[0]; var row = selectedRanges[0];
expect(selectedRanges.length).toEqual(1); expect(selectedRanges.length).toEqual(1);
expect(row.fromCell).toBe(1); expect(row.fromCell).toEqual(1);
expect(row.toCell).toBe(2); expect(row.toCell).toEqual(2);
expect(row.fromRow).toBe(0); expect(row.fromRow).toEqual(0);
expect(row.toRow).toBe(0); expect(row.toRow).toEqual(0);
} }
}); });

View File

@@ -437,12 +437,12 @@ describe('XCellSelectionModel', function () {
it('should call handleDragEnd from CellRangeSelector', function () { it('should call handleDragEnd from CellRangeSelector', function () {
var newRange = grid.getSelectionModel().getSelectedRanges(); var newRange = grid.getSelectionModel().getSelectedRanges();
expect(newRange.length).toBe(1); expect(newRange.length).toEqual(1);
expect(newRange[0].fromCell).toBe(1); expect(newRange[0].fromCell).toEqual(1);
expect(newRange[0].toCell).toBe(3); expect(newRange[0].toCell).toEqual(3);
expect(newRange[0].fromRow).toBe(1); expect(newRange[0].fromRow).toEqual(1);
expect(newRange[0].toRow).toBe(4); expect(newRange[0].toRow).toEqual(4);
}); });
}); });
}); });
@@ -482,7 +482,7 @@ describe('XCellSelectionModel', function () {
var selectedRanges = grid.getSelectionModel().getSelectedRanges(); var selectedRanges = grid.getSelectionModel().getSelectedRanges();
expect(selectedRanges.length).toBe(2); expect(selectedRanges.length).toEqual(2);
expectRangeToMatch(selectedRanges[0], 0, 1, 0, 3); expectRangeToMatch(selectedRanges[0], 0, 1, 0, 3);
expectRangeToMatch(selectedRanges[1], 2, 1, 2, 3); expectRangeToMatch(selectedRanges[1], 2, 1, 2, 3);
}); });
@@ -505,14 +505,14 @@ describe('XCellSelectionModel', function () {
function expectOneSelectedRange(fromRow, fromCell, toRow, toCell) { function expectOneSelectedRange(fromRow, fromCell, toRow, toCell) {
var selectedRanges = grid.getSelectionModel().getSelectedRanges(); var selectedRanges = grid.getSelectionModel().getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
expectRangeToMatch(selectedRanges[0], fromRow, fromCell, toRow, toCell); expectRangeToMatch(selectedRanges[0], fromRow, fromCell, toRow, toCell);
} }
function expectRangeToMatch(range, fromRow, fromCell, toRow, toCell) { function expectRangeToMatch(range, fromRow, fromCell, toRow, toCell) {
expect(range.fromRow).toBe(fromRow); expect(range.fromRow).toEqual(fromRow);
expect(range.toRow).toBe(toRow); expect(range.toRow).toEqual(toRow);
expect(range.fromCell).toBe(fromCell); expect(range.fromCell).toEqual(fromCell);
expect(range.toCell).toBe(toCell); expect(range.toCell).toEqual(toCell);
} }
}); });

View File

@@ -57,11 +57,11 @@ describe('CellSelector', function () {
$(container.find('.slick-row .slick-cell.l' + column)[row]).trigger('click'); $(container.find('.slick-row .slick-cell.l' + column)[row]).trigger('click');
var selectedRanges = cellSelectionModel.getSelectedRanges(); var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1); expect(selectedRanges.length).toEqual(1);
expect(selectedRanges[0].fromCell).toBe(0); expect(selectedRanges[0].fromCell).toEqual(0);
expect(selectedRanges[0].toCell).toBe(0); expect(selectedRanges[0].toCell).toEqual(0);
expect(selectedRanges[0].fromRow).toBe(1); expect(selectedRanges[0].fromRow).toEqual(1);
expect(selectedRanges[0].toRow).toBe(1); expect(selectedRanges[0].toRow).toEqual(1);
}); });
it('deselects previously selected ranges', function () { it('deselects previously selected ranges', function () {
@@ -74,7 +74,7 @@ describe('CellSelector', function () {
$(container.find('.slick-row .slick-cell.l' + column)[row]).trigger('click'); $(container.find('.slick-row .slick-cell.l' + column)[row]).trigger('click');
expect(RangeSelectionHelper.isRangeSelected(cellSelectionModel.getSelectedRanges(), row2Range)) expect(RangeSelectionHelper.isRangeSelected(cellSelectionModel.getSelectedRanges(), row2Range))
.toBe(false); .toEqual(false);
}); });
}); });
}); });

View File

@@ -95,7 +95,7 @@ describe('#handleQueryOutputKeyboardEvent', function () {
handleQueryOutputKeyboardEvent(event, slickEvent); handleQueryOutputKeyboardEvent(event, slickEvent);
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy(); expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
expect(grid.getSelectionModel().getSelectedRanges().length).toBe(1); expect(grid.getSelectionModel().getSelectedRanges().length).toEqual(1);
}); });
}); });
@@ -109,7 +109,7 @@ describe('#handleQueryOutputKeyboardEvent', function () {
handleQueryOutputKeyboardEvent(event, slickEvent); handleQueryOutputKeyboardEvent(event, slickEvent);
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy(); expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
expect(grid.getSelectionModel().getSelectedRanges().length).toBe(1); expect(grid.getSelectionModel().getSelectedRanges().length).toEqual(1);
}); });
}); });
}); });
@@ -125,7 +125,7 @@ describe('#handleQueryOutputKeyboardEvent', function () {
handleQueryOutputKeyboardEvent(event, slickEvent); handleQueryOutputKeyboardEvent(event, slickEvent);
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy(); expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
expect(grid.getSelectionModel().getSelectedRanges().length).toBe(1); expect(grid.getSelectionModel().getSelectedRanges().length).toEqual(1);
}); });
}); });
@@ -139,7 +139,7 @@ describe('#handleQueryOutputKeyboardEvent', function () {
handleQueryOutputKeyboardEvent(event, slickEvent); handleQueryOutputKeyboardEvent(event, slickEvent);
expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy(); expect(RangeSelectionHelper.isEntireGridSelected(grid)).toBeTruthy();
expect(grid.getSelectionModel().getSelectedRanges().length).toBe(1); expect(grid.getSelectionModel().getSelectedRanges().length).toEqual(1);
}); });
}); });
}); });

View File

@@ -1054,7 +1054,7 @@ describe('ExecuteQuery', () => {
executeQuery.execute('', {}); executeQuery.execute('', {});
setTimeout(() => { setTimeout(() => {
expect(wasNetworkCalled).toBe(false); expect(wasNetworkCalled).toEqual(false);
done(); done();
}, 0); }, 0);
}); });
@@ -1129,7 +1129,7 @@ describe('ExecuteQuery', () => {
}); });
it('reset the number of rows that were affected', () => { it('reset the number of rows that were affected', () => {
expect(sqlEditorMock.rows_affected).toBe(0); expect(sqlEditorMock.rows_affected).toEqual(0);
}); });
it('reset query start time', () => { it('reset query start time', () => {
@@ -1157,21 +1157,21 @@ describe('ExecuteQuery', () => {
it('should update the can edit flag', (done) => { it('should update the can edit flag', (done) => {
setTimeout(() => { setTimeout(() => {
expect(sqlEditorMock.can_edit).toBe(false); expect(sqlEditorMock.can_edit).toEqual(false);
done(); done();
}, 0); }, 0);
}); });
it('should update the can filter flag', (done) => { it('should update the can filter flag', (done) => {
setTimeout(() => { setTimeout(() => {
expect(sqlEditorMock.can_filter).toBe(false); expect(sqlEditorMock.can_filter).toEqual(false);
done(); done();
}, 0); }, 0);
}); });
it('should update information notifier timeout', (done) => { it('should update information notifier timeout', (done) => {
setTimeout(() => { setTimeout(() => {
expect(sqlEditorMock.info_notifier_timeout).toBe(5); expect(sqlEditorMock.info_notifier_timeout).toEqual(5);
done(); done();
}, 0); }, 0);
}); });

View File

@@ -7,7 +7,7 @@
// //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
import keyboardShortcuts from 'sources/keyboard_shortcuts'; import * as keyboardShortcuts from 'sources/keyboard_shortcuts';
import {queryToolActions} from 'sources/sqleditor/query_tool_actions'; import {queryToolActions} from 'sources/sqleditor/query_tool_actions';
import gettext from 'sources/gettext'; import gettext from 'sources/gettext';
@@ -512,30 +512,30 @@ describe('the keyboard shortcuts', () => {
}; };
it('shortcut_key',()=>{ it('shortcut_key',()=>{
expect(keyboardShortcuts.shortcut_key(shortcut)).toBe('A'); expect(keyboardShortcuts.shortcut_key(shortcut)).toEqual('A');
}); });
it('shortcut_accesskey_title',()=>{ it('shortcut_accesskey_title',()=>{
expect(keyboardShortcuts.shortcut_accesskey_title( expect(keyboardShortcuts.shortcut_accesskey_title(
'Title', shortcut)).toBe(gettext('Title (accesskey + A)')); 'Title', shortcut)).toEqual(gettext('Title (accesskey + A)'));
}); });
it('shortcut_title',()=>{ it('shortcut_title',()=>{
shortcut.alt = true, shortcut.shift = false, shortcut.control = false; shortcut.alt = true, shortcut.shift = false, shortcut.control = false;
expect(keyboardShortcuts.shortcut_title( expect(keyboardShortcuts.shortcut_title(
'Title', shortcut)).toBe(gettext('Title (Alt+A)')); 'Title', shortcut)).toEqual(gettext('Title (Alt+A)'));
shortcut.alt = false, shortcut.shift = true, shortcut.control = false; shortcut.alt = false, shortcut.shift = true, shortcut.control = false;
expect(keyboardShortcuts.shortcut_title( expect(keyboardShortcuts.shortcut_title(
'Title', shortcut)).toBe(gettext('Title (Shift+A)')); 'Title', shortcut)).toEqual(gettext('Title (Shift+A)'));
shortcut.alt = false, shortcut.shift = false, shortcut.control = true; shortcut.alt = false, shortcut.shift = false, shortcut.control = true;
expect(keyboardShortcuts.shortcut_title( expect(keyboardShortcuts.shortcut_title(
'Title', shortcut)).toBe(gettext('Title (Ctrl+A)')); 'Title', shortcut)).toEqual(gettext('Title (Ctrl+A)'));
shortcut.alt = true, shortcut.shift = true, shortcut.control = true; shortcut.alt = true, shortcut.shift = true, shortcut.control = true;
expect(keyboardShortcuts.shortcut_title( expect(keyboardShortcuts.shortcut_title(
'Title', shortcut)).toBe(gettext('Title (Alt+Shift+Ctrl+A)')); 'Title', shortcut)).toEqual(gettext('Title (Alt+Shift+Ctrl+A)'));
}); });
}); });
@@ -617,7 +617,7 @@ describe('the keyboard shortcuts', () => {
describe('stops all event propogation', () => { describe('stops all event propogation', () => {
it('should cancel the bubble', () => { it('should cancel the bubble', () => {
expect(event.cancelBubble).toBe(true); expect(event.cancelBubble).toEqual(true);
}); });
it('should prevent the default behavior', () => { it('should prevent the default behavior', () => {

View File

@@ -17,7 +17,7 @@ describe('#httpResponseRequiresNewTransaction', () => {
it('should return false', () => { it('should return false', () => {
expect(httpResponseRequiresNewTransaction({ expect(httpResponseRequiresNewTransaction({
status: 300, status: 300,
})).toBe(false); })).toEqual(false);
}); });
}); });
@@ -48,7 +48,7 @@ describe('#httpResponseRequiresNewTransaction', () => {
data: { data: {
info: 'some information', info: 'some information',
}, },
})).toBe(false); })).toEqual(false);
}); });
}); });
@@ -59,7 +59,7 @@ describe('#httpResponseRequiresNewTransaction', () => {
data: { data: {
info: 'DATAGRID_TRANSACTION_REQUIRED', info: 'DATAGRID_TRANSACTION_REQUIRED',
}, },
})).toBe(true); })).toEqual(true);
}); });
}); });
}); });
@@ -102,7 +102,7 @@ describe('#handleQueryToolAjaxError', () => {
pgBrowserMock, sqlEditorHandler, exceptionSpy, stateToSave, pgBrowserMock, sqlEditorHandler, exceptionSpy, stateToSave,
stateParameters, checkTransaction stateParameters, checkTransaction
) )
).toBe('Not connected to the server or the connection to the server has been closed.'); ).toEqual('Not connected to the server or the connection to the server has been closed.');
}); });
}); });
@@ -184,7 +184,7 @@ describe('#handleQueryToolAjaxError', () => {
pgBrowserMock, sqlEditorHandler, exceptionSpy, stateToSave, pgBrowserMock, sqlEditorHandler, exceptionSpy, stateToSave,
stateParameters, checkTransaction stateParameters, checkTransaction
) )
).toBe('ajax failed with unknown reason'); ).toEqual('ajax failed with unknown reason');
}); });
}); });

View File

@@ -8,7 +8,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
define(['sources/sqleditor_utils'], define(['sources/sqleditor_utils'],
function (SqlEditorUtils) { function (SqlEditorUtils) {
describe('SqlEditorUtils', function () { describe('SqlEditorUtils', function () {
describe('Generate a random string of size 10', function () { describe('Generate a random string of size 10', function () {
@@ -93,4 +93,4 @@ function (SqlEditorUtils) {
}); });
}); });
}); });
}); });

View File

@@ -51,7 +51,7 @@ describe('#enableTriggers', () => {
}); });
setTimeout(() => { setTimeout(() => {
expect(enableTriggers(tree, alertify, generateUrlSpy, {})).toBe(false); expect(enableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
done(); done();
}, 0); }, 0);
}); });
@@ -66,7 +66,7 @@ describe('#enableTriggers', () => {
}); });
setTimeout(() => { setTimeout(() => {
expect(enableTriggers(tree, alertify, generateUrlSpy, {})).toBe(false); expect(enableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
}, 0); }, 0);
}); });
}); });
@@ -134,7 +134,7 @@ describe('#enableTriggers', () => {
enableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]}); enableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
setTimeout(() => { setTimeout(() => {
expect(tree.findNodeByDomElement([{id: 'table1'}]).children.length).toBe(0); expect(tree.findNodeByDomElement([{id: 'table1'}]).children.length).toEqual(0);
done(); done();
}, 20); }, 20);
}); });
@@ -178,7 +178,7 @@ describe('#disableTriggers', () => {
}); });
setTimeout(() => { setTimeout(() => {
expect(disableTriggers(tree, alertify, generateUrlSpy, {})).toBe(false); expect(disableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
done(); done();
}, 0); }, 0);
}); });
@@ -193,7 +193,7 @@ describe('#disableTriggers', () => {
}); });
setTimeout(() => { setTimeout(() => {
expect(disableTriggers(tree, alertify, generateUrlSpy, {})).toBe(false); expect(disableTriggers(tree, alertify, generateUrlSpy, {})).toEqual(false);
}, 0); }, 0);
}); });
}); });
@@ -261,7 +261,7 @@ describe('#disableTriggers', () => {
disableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]}); disableTriggers(tree, alertify, generateUrlSpy, {item: [{id: 'table1'}]});
setTimeout(() => { setTimeout(() => {
expect(tree.findNodeByDomElement([{id: 'table1'}]).children.length).toBe(0); expect(tree.findNodeByDomElement([{id: 'table1'}]).children.length).toEqual(0);
done(); done();
}, 20); }, 20);
}); });

View File

@@ -12,6 +12,7 @@ import {pgBrowser, browserTreeState} from '../../../pgadmin/static/js/tree/pgadm
describe('#browserTreeState', () => { describe('#browserTreeState', () => {
beforeEach(() => { beforeEach(() => {
pgBrowser.Nodes = { pgBrowser.Nodes = {
server_group: { server_group: {
_type: 'server_group', _type: 'server_group',
@@ -192,10 +193,9 @@ describe('#browserTreeState', () => {
expect(browserTreeState.current_state, {1: {'paths': ['server_group/1,server/1,coll_database/1','database/10']}}); expect(browserTreeState.current_state, {1: {'paths': ['server_group/1,server/1,coll_database/1','database/10']}});
}); });
}); });
});
describe('When node is closed, node should get removed from the tree state cache', () => {
describe('When coll_database node is closed, both database and coll_database should be removed', () => { describe('When coll_database node is closed, both database and coll_database should be removed', () => {
let item = { let item = {
_type: 'coll_database', _type: 'coll_database',
@@ -212,6 +212,7 @@ describe('#browserTreeState', () => {
}); });
it('The tree current state will remove coll_database and database', () => { it('The tree current state will remove coll_database and database', () => {
browserTreeState.update_cache(item);
browserTreeState.remove_from_cache(item); browserTreeState.remove_from_cache(item);
expect(browserTreeState.current_state, {1: {'paths': ['server_group/1,server/1']}}); expect(browserTreeState.current_state, {1: {'paths': ['server_group/1,server/1']}});
}); });

View File

@@ -32,7 +32,7 @@ const treeTests = (treeClass, setDefaultCallBack) => {
it('return false for #hasParent()', () => { it('return false for #hasParent()', () => {
const node = tree.findNode(['some new node']); const node = tree.findNode(['some new node']);
expect(node.hasParent()).toBe(false); expect(node.hasParent()).toEqual(false);
}); });
it('return null for #parent()', () => { it('return null for #parent()', () => {
@@ -53,7 +53,7 @@ const treeTests = (treeClass, setDefaultCallBack) => {
it('return false for #hasParent()', () => { it('return false for #hasParent()', () => {
const node = tree.findNode(['some new node']); const node = tree.findNode(['some new node']);
expect(node.hasParent()).toBe(false); expect(node.hasParent()).toEqual(false);
}); });
it('return null for #parent()', () => { it('return null for #parent()', () => {
@@ -74,7 +74,7 @@ const treeTests = (treeClass, setDefaultCallBack) => {
it('return false for #hasParent()', () => { it('return false for #hasParent()', () => {
const node = tree.findNode(['some new node']); const node = tree.findNode(['some new node']);
expect(node.hasParent()).toBe(false); expect(node.hasParent()).toEqual(false);
}); });
it('return null for #parent()', () => { it('return null for #parent()', () => {
@@ -99,7 +99,7 @@ const treeTests = (treeClass, setDefaultCallBack) => {
it('return true for #hasParent()', () => { it('return true for #hasParent()', () => {
const node = tree.findNode(['parent node', 'some new node']); const node = tree.findNode(['parent node', 'some new node']);
expect(node.hasParent()).toBe(true); expect(node.hasParent()).toEqual(true);
}); });
it('return "parent node" object for #parent()', () => { it('return "parent node" object for #parent()', () => {
@@ -119,7 +119,7 @@ const treeTests = (treeClass, setDefaultCallBack) => {
tree.addNewNode('some new node', {data: 'interesting 1'}, undefined, ['parent' + tree.addNewNode('some new node', {data: 'interesting 1'}, undefined, ['parent' +
' node']); ' node']);
const parentNode = tree.findNode(['parent node']); const parentNode = tree.findNode(['parent node']);
expect(parentNode.children.length).toBe(1); expect(parentNode.children.length).toEqual(1);
}); });
it('updates the existing node data', () => { it('updates the existing node data', () => {
@@ -217,20 +217,20 @@ describe('tree tests', () => {
context('parent is null', () => { context('parent is null', () => {
it('returns false', () => { it('returns false', () => {
let treeNode = new TreeNode('123', {}, [], null); let treeNode = new TreeNode('123', {}, [], null);
expect(treeNode.hasParent()).toBe(false); expect(treeNode.hasParent()).toEqual(false);
}); });
}); });
context('parent is undefined', () => { context('parent is undefined', () => {
it('returns false', () => { it('returns false', () => {
let treeNode = new TreeNode('123', {}, [], undefined); let treeNode = new TreeNode('123', {}, [], undefined);
expect(treeNode.hasParent()).toBe(false); expect(treeNode.hasParent()).toEqual(false);
}); });
}); });
context('parent exists', () => { context('parent exists', () => {
it('returns true', () => { it('returns true', () => {
let parentNode = new TreeNode('456', {}, []); let parentNode = new TreeNode('456', {}, []);
let treeNode = new TreeNode('123', {}, [], parentNode); let treeNode = new TreeNode('123', {}, [], parentNode);
expect(treeNode.hasParent()).toBe(true); expect(treeNode.hasParent()).toEqual(true);
}); });
}); });
}); });
@@ -337,13 +337,13 @@ describe('tree tests', () => {
context('node is at the first level', () => { context('node is at the first level', () => {
it('returns false', () => { it('returns false', () => {
expect(tree.hasParent([{id: 'level1'}])).toBe(false); expect(tree.hasParent([{id: 'level1'}])).toEqual(false);
}); });
}); });
context('node is at the second level', () => { context('node is at the second level', () => {
it('returns true', () => { it('returns true', () => {
expect(tree.hasParent([{id: 'level2'}])).toBe(true); expect(tree.hasParent([{id: 'level2'}])).toEqual(true);
}); });
}); });
}); });

View File

@@ -18,37 +18,15 @@ const sourceDir = __dirname + '/pgadmin/static';
const webpackShimConfig = require('./webpack.shim'); const webpackShimConfig = require('./webpack.shim');
const PRODUCTION = process.env.NODE_ENV === 'production'; const PRODUCTION = process.env.NODE_ENV === 'production';
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const extractStyle = new ExtractTextPlugin({ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const extractStyle = new MiniCssExtractPlugin({
filename: '[name].css', filename: '[name].css',
allChunks: true, allChunks: true,
}); });
const envType = PRODUCTION ? 'production': 'development'; const envType = PRODUCTION ? 'production': 'development';
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
// Extract vendor related libraries(node_modules/lib/lib.js) from bundles
// specified in `chunks` into vendor.js bundle
const vendorChunks = new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
chunks: ['app.bundle', 'sqleditor', 'codemirror', 'debugger_direct'],
filename: 'vendor.js',
minChunks: function(module) {
return webpackShimConfig.isExternal(module);
},
});
// Extract pgAdmin common libraries(pgadmin/web/module/filename.js) from bundles
// specified in `chunks` into pgadmin_commons.js bundle.
// pgLibs holds files that will be moved into this bundle.
const pgAdminCommonChunks = new webpack.optimize.CommonsChunkPlugin({
name: 'pgadmin_commons',
chunks: ['app.bundle', 'sqleditor', 'codemirror', 'debugger_direct'],
filename: 'pgadmin_commons.js',
minChunks: function(module) {
return webpackShimConfig.isPgAdminLib(module);
},
});
// Expose libraries in app context so they need not to // Expose libraries in app context so they need not to
// require('libname') when used in a module // require('libname') when used in a module
const providePlugin = new webpack.ProvidePlugin({ const providePlugin = new webpack.ProvidePlugin({
@@ -64,17 +42,6 @@ const providePlugin = new webpack.ProvidePlugin({
'window.moment':'moment', 'window.moment':'moment',
}); });
// Minify and omptimize JS/CSS to reduce bundle size. It is used in production
const uglifyPlugin = new webpack.optimize.UglifyJsPlugin({
output: {comments: false},
compress: {
warnings: false,
unused: true,
dead_code: true,
drop_console: true,
},
});
// Optimize CSS Assets by removing comments while bundling // Optimize CSS Assets by removing comments while bundling
const optimizeAssetsPlugin = new OptimizeCssAssetsPlugin({ const optimizeAssetsPlugin = new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.css$/g, assetNameRegExp: /\.css$/g,
@@ -83,15 +50,6 @@ const optimizeAssetsPlugin = new OptimizeCssAssetsPlugin({
canPrint: true, canPrint: true,
}); });
// Helps in minimising the `React' production bundle. Bundle only code
// requires in production mode. React keeps the code conditional
// based on 'NODE_ENV' variable. [used only in production]
const definePlugin = new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
},
});
// Manages the cache and stores it into 'sources/generated/.cache/<env><hash>/' path // Manages the cache and stores it into 'sources/generated/.cache/<env><hash>/' path
// where env = dev || prod // where env = dev || prod
const hardSourceWebpackPlugin = new HardSourceWebpackPlugin({ const hardSourceWebpackPlugin = new HardSourceWebpackPlugin({
@@ -164,6 +122,8 @@ for(let i=0; i<webpackShimConfig.css_bundle_include.length; i++) {
pushModulesCss(path.join(__dirname,'./pgadmin'), pgadminStyles); pushModulesCss(path.join(__dirname,'./pgadmin'), pgadminStyles);
module.exports = { module.exports = {
mode: envType,
devtool: false,
stats: { children: false }, stats: { children: false },
// The base directory, an absolute path, for resolving entry points and loaders // The base directory, an absolute path, for resolving entry points and loaders
// from configuration. // from configuration.
@@ -206,8 +166,7 @@ module.exports = {
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: ['es2015'], presets: [['@babel/preset-env', {'modules': 'commonjs'}]],
plugins: ['transform-object-rest-spread'],
}, },
}, },
}, { }, {
@@ -215,7 +174,7 @@ module.exports = {
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: ['es2015'], presets: [['@babel/preset-env', {'modules': 'commonjs'}]],
}, },
}, },
}, { }, {
@@ -362,28 +321,25 @@ module.exports = {
exclude: /vendor/, exclude: /vendor/,
}, { }, {
test: /\.scss$/, test: /\.scss$/,
use: extractStyle.extract({ use: [
use: [{ {loader: MiniCssExtractPlugin.loader},
loader: 'css-loader', {loader: 'css-loader'},
}, { {loader: 'sass-loader'},
loader: 'sass-loader', // compiles Sass to CSS {
}, {
/* This will @import with below resources to all scss files */
loader: 'sass-resources-loader', loader: 'sass-resources-loader',
options: { options: {
resources: [ resources: [
'./pgadmin/static/scss/resources/pgadmin.resources.scss', './pgadmin/static/scss/resources/pgadmin.resources.scss',
], ],
}, },
}], },
}), ],
}, { }, {
test: /\.css$/, test: /\.css$/,
use: extractStyle.extract({ use: [
use: [{ MiniCssExtractPlugin.loader,
loader: 'css-loader', 'css-loader',
}], ],
}),
}], }],
// Prevent module from parsing through webpack, helps in reducing build time // Prevent module from parsing through webpack, helps in reducing build time
noParse: [/moment.js/], noParse: [/moment.js/],
@@ -403,23 +359,55 @@ module.exports = {
poll: 1000, poll: 1000,
ignored: /node_modules/, ignored: /node_modules/,
}, },
// Webpack 4: uglifyPlugin moved from plugins to optimization
optimization: {
minimizer: [
new UglifyJsPlugin({
parallel: true,
cache: true,
uglifyOptions: {
compress: false,
},
}),
],
splitChunks: {
cacheGroups: {
vendors: {
name: 'vendors',
filename: 'vendor.js',
chunks: 'all',
reuseExistingChunk: true,
priority: 1,
minChunks: 2,
enforce: true,
test(module) {
return webpackShimConfig.isExternal(module);
},
},
secondary: {
name: 'pgadmin_commons',
filename: 'pgadmin_commons.js',
chunks: 'all',
priority: 2,
minChunks: 2,
enforce: true,
test(module) {
return webpackShimConfig.isPgAdminLib(module);
},
},
},
},
},
// Define list of Plugins used in Production or development mode // Define list of Plugins used in Production or development mode
// Ref:https://webpack.js.org/concepts/plugins/#components/sidebar/sidebar.jsx // Ref:https://webpack.js.org/concepts/plugins/#components/sidebar/sidebar.jsx
plugins: PRODUCTION ? [ plugins: PRODUCTION ? [
extractStyle, extractStyle,
vendorChunks,
pgAdminCommonChunks,
providePlugin, providePlugin,
uglifyPlugin,
optimizeAssetsPlugin, optimizeAssetsPlugin,
definePlugin,
sourceMapDevToolPlugin, sourceMapDevToolPlugin,
]: [ ]: [
extractStyle, extractStyle,
vendorChunks,
pgAdminCommonChunks,
providePlugin, providePlugin,
definePlugin,
hardSourceWebpackPlugin, hardSourceWebpackPlugin,
sourceMapDevToolPlugin, sourceMapDevToolPlugin,
], ],

View File

@@ -138,7 +138,7 @@ var webpackShimConfig = {
'translations': path.join(__dirname, './pgadmin/tools/templates/js/translations'), 'translations': path.join(__dirname, './pgadmin/tools/templates/js/translations'),
'sources/gettext': path.join(__dirname, './pgadmin/static/js/gettext'), 'sources/gettext': path.join(__dirname, './pgadmin/static/js/gettext'),
'sources/utils': path.join(__dirname, './pgadmin/static/js/utils'), 'sources/utils': path.join(__dirname, './pgadmin/static/js/utils'),
'babel-polyfill': path.join(__dirname, './node_modules/babel-polyfill/dist/polyfill'), 'babel-polyfill': path.join(__dirname, './node_modules/@babel/polyfill/dist/polyfill'),
'tools': path.join(__dirname, './pgadmin/tools/'), 'tools': path.join(__dirname, './pgadmin/tools/'),
'pgbrowser': path.join(__dirname, './pgadmin/browser/static/js/'), 'pgbrowser': path.join(__dirname, './pgadmin/browser/static/js/'),

View File

@@ -36,8 +36,8 @@ module.exports = {
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: ['es2015'], presets: [['@babel/preset-env', {'modules': 'commonjs'}]],
plugins: ['transform-object-rest-spread'], sourceMap: 'inline',
}, },
}, },
}, { }, {

File diff suppressed because it is too large Load Diff