diff --git a/Gruntfile.js b/Gruntfile.js index 35cfc7b8d4d8..52033d91c9a2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -83,6 +83,7 @@ module.exports = function(grunt) { tests: { jqlite: 'karma-jqlite.conf.js', jquery: 'karma-jquery.conf.js', + 'jquery-2.2': 'karma-jquery-2.2.conf.js', 'jquery-2.1': 'karma-jquery-2.1.conf.js', docs: 'karma-docs.conf.js', modules: 'karma-modules.conf.js' @@ -92,6 +93,7 @@ module.exports = function(grunt) { autotest: { jqlite: 'karma-jqlite.conf.js', jquery: 'karma-jquery.conf.js', + 'jquery-2.2': 'karma-jquery-2.2.conf.js', 'jquery-2.1': 'karma-jquery-2.1.conf.js', modules: 'karma-modules.conf.js', docs: 'karma-docs.conf.js' @@ -364,10 +366,11 @@ module.exports = function(grunt) { grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', 'package', 'test:unit', 'test:promises-aplus', 'tests:docs', 'test:protractor']); grunt.registerTask('test:jqlite', 'Run the unit tests with Karma' , ['tests:jqlite']); grunt.registerTask('test:jquery', 'Run the jQuery (latest) unit tests with Karma', ['tests:jquery']); + grunt.registerTask('test:jquery-2.2', 'Run the jQuery 2.2 unit tests with Karma', ['tests:jquery-2.2']); grunt.registerTask('test:jquery-2.1', 'Run the jQuery 2.1 unit tests with Karma', ['tests:jquery-2.1']); grunt.registerTask('test:modules', 'Run the Karma module tests with Karma', ['build', 'tests:modules']); grunt.registerTask('test:docs', 'Run the doc-page tests with Karma', ['package', 'tests:docs']); - grunt.registerTask('test:unit', 'Run unit, jQuery and Karma module tests with Karma', ['test:jqlite', 'test:jquery', 'test:jquery-2.1', 'test:modules']); + grunt.registerTask('test:unit', 'Run unit, jQuery and Karma module tests with Karma', ['test:jqlite', 'test:jquery', 'test:jquery-2.2', 'test:jquery-2.1', 'test:modules']); grunt.registerTask('test:protractor', 'Run the end to end tests with Protractor and keep a test server running in the background', ['webdriver', 'connect:testserver', 'protractor:normal']); grunt.registerTask('test:travis-protractor', 'Run the end to end tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor:travis']); grunt.registerTask('test:ci-protractor', 'Run the end to end tests with Protractor for Jenkins CI builds', ['webdriver', 'connect:testserver', 'protractor:jenkins']); diff --git a/angularFiles.js b/angularFiles.js index 0513de6742fe..71edff31c567 100755 --- a/angularFiles.js +++ b/angularFiles.js @@ -236,15 +236,6 @@ var angularFiles = { '@angularTest' ], - 'karmaJqueryOld': [ - 'bower_components/jquery-2.1/dist/jquery.js', - 'test/jquery_alias.js', - '@angularSrc', - '@angularSrcModules', - '@angularScenario', - '@angularTest' - ], - 'karmaJqueryExclude': [ 'src/angular-bootstrap.js', 'src/ngScenario/angular-bootstrap.js', @@ -253,6 +244,17 @@ var angularFiles = { ] }; +['2.1', '2.2'].forEach(function (jQueryVersion) { + angularFiles['karmaJquery' + jQueryVersion] = [] + .concat(angularFiles.karmaJquery) + .map(function (path) { + if (path.startsWith('bower_components/jquery')) { + return path.replace(/^bower_components\/jquery/, 'bower_components/jquery-' + jQueryVersion); + } + return path; + }); +}); + angularFiles['angularSrcModules'] = [].concat( angularFiles['angularModules']['ngAnimate'], angularFiles['angularModules']['ngMessageFormat'], diff --git a/bower.json b/bower.json index 20c425e22f7a..efdf0fe3403c 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,8 @@ "name": "AngularJS", "license": "MIT", "devDependencies": { - "jquery": "2.2.3", + "jquery": "3.1.0", + "jquery-2.2": "jquery#2.2.4", "jquery-2.1": "jquery#2.1.4", "closure-compiler": "https://dl.google.com/closure-compiler/compiler-20140814.zip", "ng-closure-runner": "https://raw.github.com/angular/ng-closure-runner/v0.2.3/assets/ng-closure-runner.zip" diff --git a/karma-jquery-2.1.conf.js b/karma-jquery-2.1.conf.js index 7ea14d91dd8e..b9d4275e5f58 100644 --- a/karma-jquery-2.1.conf.js +++ b/karma-jquery-2.1.conf.js @@ -1,18 +1,5 @@ 'use strict'; -var angularFiles = require('./angularFiles'); -var sharedConfig = require('./karma-shared.conf'); +var karmaConfigFactory = require('./karma-jquery.conf-factory'); -module.exports = function(config) { - sharedConfig(config, {testName: 'AngularJS: jQuery', logFile: 'karma-jquery.log'}); - - config.set({ - files: angularFiles.mergeFilesFor('karmaJqueryOld'), - exclude: angularFiles.mergeFilesFor('karmaJqueryExclude'), - - junitReporter: { - outputFile: 'test_out/jquery.xml', - suite: 'jQuery' - } - }); -}; +module.exports = karmaConfigFactory('2.1'); diff --git a/karma-jquery-2.2.conf.js b/karma-jquery-2.2.conf.js new file mode 100644 index 000000000000..1d07d68e97d4 --- /dev/null +++ b/karma-jquery-2.2.conf.js @@ -0,0 +1,5 @@ +'use strict'; + +var karmaConfigFactory = require('./karma-jquery.conf-factory'); + +module.exports = karmaConfigFactory('2.2'); diff --git a/karma-jquery.conf-factory.js b/karma-jquery.conf-factory.js new file mode 100644 index 000000000000..993bca028997 --- /dev/null +++ b/karma-jquery.conf-factory.js @@ -0,0 +1,25 @@ +'use strict'; + +var angularFiles = require('./angularFiles'); +var sharedConfig = require('./karma-shared.conf'); + +module.exports = function (version) { + version = version || ''; + + return function(config) { + sharedConfig(config, { + testName: 'AngularJS: jQuery' + (version ? ' ' + version : ''), + logFile: 'karma-jquery' + version + '.log' + }); + + config.set({ + files: angularFiles.mergeFilesFor('karmaJquery' + version), + exclude: angularFiles.mergeFilesFor('karmaJqueryExclude'), + + junitReporter: { + outputFile: 'test_out/jquery.xml', + suite: 'jQuery' + } + }); + }; +}; diff --git a/karma-jquery.conf.js b/karma-jquery.conf.js index c7db1c25255a..38597296658d 100644 --- a/karma-jquery.conf.js +++ b/karma-jquery.conf.js @@ -1,18 +1,5 @@ 'use strict'; -var angularFiles = require('./angularFiles'); -var sharedConfig = require('./karma-shared.conf'); +var karmaConfigFactory = require('./karma-jquery.conf-factory'); -module.exports = function(config) { - sharedConfig(config, {testName: 'AngularJS: jQuery', logFile: 'karma-jquery.log'}); - - config.set({ - files: angularFiles.mergeFilesFor('karmaJquery'), - exclude: angularFiles.mergeFilesFor('karmaJqueryExclude'), - - junitReporter: { - outputFile: 'test_out/jquery.xml', - suite: 'jQuery' - } - }); -}; +module.exports = karmaConfigFactory(); diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 17f1a6b26f74..2cd5b092a464 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -1912,7 +1912,14 @@ describe('select', function() { optionElements = element.find('option'); expect(optionElements.length).toEqual(1); expect(scope.obj.value).toEqual([]); - expect(element.val()).toBe(null); + + // Cover both jQuery 3.x ([]) and 2.x (null) behavior. + var val = element.val(); + if (val === null) { + val = []; + } + expect(val).toEqual([]); + expect(ngModelCtrlSpy).toHaveBeenCalledTimes(1); }); @@ -1970,7 +1977,14 @@ describe('select', function() { optionElements = element.find('option'); expect(optionElements.length).toEqual(3); expect(scope.obj.value).toEqual([]); - expect(element.val()).toBe(null); + + // Cover both jQuery 3.x ([]) and 2.x (null) behavior. + var val = element.val(); + if (val === null) { + val = []; + } + expect(val).toEqual([]); + expect(ngModelCtrlSpy).toHaveBeenCalledTimes(1); });