tests(jQuery): make the tests pass on jQuery 3.0.0-beta1

Closes #14229
This commit is contained in:
Michał Gołębiowski
2016-03-14 22:59:35 +01:00
committed by Peter Bacon Darwin
parent 5b2f6fa91f
commit b8343e213f
3 changed files with 22 additions and 3 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ angular.scenario.Application.prototype.navigateTo = function(url, loadFn, errorF
self.context.find('#test-frames').append('<iframe>');
frame = self.getFrame_();
frame.load(function() {
frame.on('load', function() {
frame.off();
try {
var $window = self.getWindow_();
+14 -1
View File
@@ -1017,11 +1017,24 @@ describe('jqLite', function() {
'<option>test 2</option>' +
'</select>').val()).toEqual(['test 1']);
// In jQuery >= 3.0 .val() on select[multiple] with no selected options returns an
// empty array, not null.
// See https://github.com/jquery/jquery/issues/2562 for more details.
// jqLite will align with jQuery 3.0 behavior in Angular 1.6.
var val;
var jQueryVersion = window.jQuery && window.jQuery.fn.jquery.split('.')[0];
var jQuery3xOrNewer = jQueryVersion && (Number(jQueryVersion) >= 3);
if (!_jqLiteMode && jQuery3xOrNewer) {
val = [];
} else {
val = null;
}
expect(jqLite(
'<select multiple>' +
'<option>test 1</option>' +
'<option>test 2</option>' +
'</select>').val()).toEqual(null);
'</select>').val()).toEqual(val);
});
});
+7 -1
View File
@@ -48,7 +48,13 @@ function MockWindow(options) {
this.fire = function(name) {
forEach(events[name], function(fn) {
fn({type: name}); // type to make jQuery happy
// type/target to make jQuery happy
fn({
type: name,
target: {
nodeType: 1
}
});
});
};