Update jQuery to 3.3.1. Fixes #3271

Patch by Aditya, with test enhancements from Anthony and Joao at Pivotal.
This commit is contained in:
Aditya Toshniwal
2018-05-25 16:26:37 +01:00
committed by Dave Page
parent 61d8072a8c
commit 9f13865777
32 changed files with 120 additions and 154 deletions

View File

@@ -273,7 +273,7 @@ describe('ColumnSelector', function () {
describe('when the column is not selectable', function () {
it('does not select the column', function () {
$(container.find('.slick-header-column:contains(some-non-selectable-column)')).click();
$(container.find('.slick-header-column:contains(some-non-selectable-column)')).trigger('click');
var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toEqual(0);

View File

@@ -68,7 +68,7 @@ describe('GridSelector', function () {
describe('when the cell for the select/deselect all is clicked', function () {
it('selects the whole grid', function () {
container.find('[title=\'Select/Deselect All\']').parent().click();
container.find('[title=\'Select/Deselect All\']').parent().trigger('click');
var selectedRanges = xCellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1);
@@ -80,7 +80,7 @@ describe('GridSelector', function () {
});
it('adds selected class', function () {
container.find('[title=\'Select/Deselect All\']').parent().click();
container.find('[title=\'Select/Deselect All\']').parent().trigger('click');
expect($(container.find('[data-id=\'select-all\']')).hasClass('selected')).toBeTruthy();
});
@@ -89,7 +89,7 @@ describe('GridSelector', function () {
describe('when the select all button in the corner gets selected', function () {
it('selects all the cells', function () {
container.find('[title=\'Select/Deselect All\']').click();
container.find('[title=\'Select/Deselect All\']').trigger('click');
var selectedRanges = xCellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1);
@@ -102,11 +102,11 @@ describe('GridSelector', function () {
describe('when the select all button in the corner gets deselected', function () {
beforeEach(function () {
container.find('[title=\'Select/Deselect All\']').click();
container.find('[title=\'Select/Deselect All\']').trigger('click');
});
it('deselects all the cells', function () {
container.find('[title=\'Select/Deselect All\']').click();
container.find('[title=\'Select/Deselect All\']').trigger('click');
var selectedRanges = xCellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(0);
@@ -115,11 +115,11 @@ describe('GridSelector', function () {
describe('and then the underlying selection changes', function () {
beforeEach(function () {
container.find('[title=\'Select/Deselect All\']').click();
container.find('[title=\'Select/Deselect All\']').trigger('click');
});
it('removes the selected class', function () {
container.find('[title=\'Select/Deselect All\']').parent().click();
container.find('[title=\'Select/Deselect All\']').parent().trigger('click');
expect($(container.find('[data-id=\'select-all\']')).hasClass('selected')).toBeFalsy();
});

View File

@@ -54,7 +54,7 @@ describe('CellSelector', function () {
describe('when the user clicks or tabs to a cell', function () {
it('sets the selected range to that cell', function () {
var row = 1, column = 0;
$(container.find('.slick-row .slick-cell.l' + column)[row]).click();
$(container.find('.slick-row .slick-cell.l' + column)[row]).trigger('click');
var selectedRanges = cellSelectionModel.getSelectedRanges();
expect(selectedRanges.length).toBe(1);
@@ -71,7 +71,7 @@ describe('CellSelector', function () {
cellSelectionModel.setSelectedRanges(ranges);
var row = 4, column = 1;
$(container.find('.slick-row .slick-cell.l' + column)[row]).click();
$(container.find('.slick-row .slick-cell.l' + column)[row]).trigger('click');
expect(RangeSelectionHelper.isRangeSelected(cellSelectionModel.getSelectedRanges(), row2Range))
.toBe(false);

View File

@@ -25,7 +25,7 @@ describe('ExecuteQuery', () => {
const startTime = new Date(2018, 1, 29, 12, 15, 52);
beforeEach(() => {
networkMock = new MockAdapter(axios);
jasmine.addMatchers({jQuerytoHaveBeenCalledWith: jQuerytoHaveBeenCalledWith});
// jasmine.addMatchers({jQuerytoHaveBeenCalledWith: jQuerytoHaveBeenCalledWith});
userManagementMock = jasmine.createSpyObj('UserManagement', [
'isPgaLoginRequired',
'pgaLogin',
@@ -1074,15 +1074,24 @@ describe('ExecuteQuery', () => {
context('when the SQL statement is not empty', () => {
let pollSpy;
let jqueryPropSpy;
beforeEach(() => {
jqueryPropSpy = spyOn($.fn, 'prop');
sqlEditorMock.gridView = {};
sqlEditorMock.gridView.query_tool_obj = jasmine.createSpyObj(
'QueryToolObject',
['removeLineClass']
);
$('body').append(
'<div id="test-id">' +
'<button id="btn-flash" disabled></button>' +
'<button id="btn-cancel-query"></button>' +
'</div>'
);
});
afterEach(function () {
$('body').remove('#test-id');
});
describe('before the backend request', () => {
@@ -1108,15 +1117,15 @@ describe('ExecuteQuery', () => {
});
it('disables the run query button', () => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-flash');
let buttonFlash = $('#btn-flash');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
});
it('enable the cancel query button', () => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', false);
expect(buttonFlash.prop('disabled')).toEqual(false);
});
it('disable the query tool buttons', () => {
@@ -1235,9 +1244,9 @@ describe('ExecuteQuery', () => {
it('disable the cancel query button', (done) => {
setTimeout(() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@@ -1355,9 +1364,9 @@ describe('ExecuteQuery', () => {
it('should disable the cancel button', (done) => {
setTimeout(
() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@@ -1413,9 +1422,9 @@ describe('ExecuteQuery', () => {
it('should disable the cancel button', (done) => {
setTimeout(
() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@@ -1481,9 +1490,9 @@ describe('ExecuteQuery', () => {
it('should disable the cancel button', (done) => {
setTimeout(
() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@@ -1552,9 +1561,9 @@ describe('ExecuteQuery', () => {
it('should disable the cancel button', (done) => {
setTimeout(
() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@@ -1626,9 +1635,9 @@ describe('ExecuteQuery', () => {
it('should disable the cancel button', (done) => {
setTimeout(
() => {
const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query');
let buttonFlash = $('#btn-cancel-query');
expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true);
expect(buttonFlash.prop('disabled')).toEqual(true);
done();
}, 0);
});
@@ -1682,43 +1691,5 @@ describe('ExecuteQuery', () => {
});
});
let findJQueryCallWithSelector = (jquerySpy, selector) => {
let result = undefined;
jquerySpy.calls.all().forEach((call) => {
if (call.object.selector === selector) {
result = call;
}
});
return result;
};
});
const jQuerytoHaveBeenCalledWith = function (util) {
return {
compare: function (actual) {
let result = {};
let expectedArgs = jasmine.util.argsToArray(arguments).slice(1);
if (actual.object === undefined || actual.object.selector === undefined) {
throw new Error('Expected a JQuery object, but got ' + jasmine.pp(actual) + '.');
}
result.pass = util.equals(actual.args, expectedArgs, '');
if (result.pass) {
result.message = 'larifo';
} else {
result.message =
'Expected jquery with selector "' +
actual.object.selector +
'" to have been called with ' +
jasmine.pp(expectedArgs) +
' but was called with ' +
jasmine.pp(actual.args);
}
return result;
},
};
};