diff --git a/Gruntfile.js b/Gruntfile.js index be56ac1ed3bb0a1f42a2a6b6f0911f59df0d771a..05ef19e2e5c317dafde9ca5be9edd690f33c12f8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,8 +9,7 @@ module.exports = function (grunt) { // Required plugins // _____________________________________________ - var specRunner = require('./dev/tests/js/framework/spec_runner'); - specRunner.init(grunt); + var specRunner = require('./dev/tests/js/framework/spec_runner')(grunt); require('./dev/tools/grunt/tasks/mage-minify')(grunt); @@ -489,10 +488,10 @@ module.exports = function (grunt) { template: require('grunt-template-jasmine-requirejs'), ignoreEmpty: true }, - 'backend-unit': specRunner.build('unit', 'adminhtml', 8000), - 'backend-integration': specRunner.build('integration', 'adminhtml', 8000), - 'frontend-unit': specRunner.build('unit', 'frontend', 3000), - 'frontend-integration': specRunner.build('integration', 'frontend', 3000) + 'backend-unit': specRunner.configure('unit', 'adminhtml', 8000), + 'backend-integration': specRunner.configure('integration', 'adminhtml', 8000), + 'frontend-unit': specRunner.configure('unit', 'frontend', 3000), + 'frontend-integration': specRunner.configure('integration', 'frontend', 3000) } }); diff --git a/dev/tests/js/framework/spec_runner.js b/dev/tests/js/framework/spec_runner.js index 153ae56f36b3a6567f9a219b5fac11cccdd4c21f..d5b6d7332082e8b4d0af345e0602b2c395306ad4 100644 --- a/dev/tests/js/framework/spec_runner.js +++ b/dev/tests/js/framework/spec_runner.js @@ -2,14 +2,33 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) */ -/* global __dirname: true */ - /** - * Initializes 'specRunner' grunt task. + * Creates jasmine configuration object * - * @param {Object} grunt + * @param {String} type - type of tests + * @param {String} dir - area dir + * @param {Number} port - port to run on + * @return {Object} */ -module.exports.init = function (grunt) { +function buildConfig(type, dir, port) { + 'use strict'; + + return { + src: '<%= path.spec %>/shim.js', + options: { + host: 'http://localhost:' + port, + specs: '<%= path.spec %>/' + type + '/**/' + dir + '/**/*Spec.js', + templateOptions: { + requireConfigFile: [ + '<%= path.spec %>/require.config.js', + '<%= path.spec %>/' + type + '/config/' + dir + '.js' + ] + } + } + }; +} + +module.exports = function (grunt) { 'use strict'; var connect = require('connect'), @@ -167,27 +186,6 @@ module.exports.init = function (grunt) { function canModify(url) { return url.match(/^\/(\.grunt)|(dev\/tests)|(dev\\tests)|(_SpecRunner\.html)/) === null; } -}; -/** - * Creates jasmine configuration object - * - * @param {String} type - type of tests - * @param {String} dir - area dir - * @param {Number} port - port to run on - * @return {Object} - */ -module.exports.build = function (type, dir, port) { - 'use strict'; - - return { - src: '<%= path.spec %>/env.js', - options: { - host: 'http://localhost:' + port, - specs: '<%= path.spec %>/' + type + '/**/' + dir + '/**/*Spec.js', - templateOptions: { - requireConfigFile: '<%= path.spec %>/' + type + '/config.js' - } - } - }; + return { configure: buildConfig }; }; diff --git a/dev/tests/js/spec/integration/Magento/PageCache/frontend/js/pageCacheSpec.js b/dev/tests/js/spec/integration/Magento/PageCache/frontend/js/pageCacheSpec.js index a1c8a63fab3f1ad8a09b036c5a5c5898afc8dee3..14a609c9361d023773bed2cf6b0ae5570c9f160b 100644 --- a/dev/tests/js/spec/integration/Magento/PageCache/frontend/js/pageCacheSpec.js +++ b/dev/tests/js/spec/integration/Magento/PageCache/frontend/js/pageCacheSpec.js @@ -16,25 +16,6 @@ define([ ], function ($) { 'use strict'; - if (!Function.prototype.bind) { - /** - * @param {Object} bind - * @returns {Function} - */ - Function.prototype.bind = function (bind) { - var self = this; - - /** - * @returns {Function} - */ - return function () { - var args = Array.prototype.slice.call(arguments); - - return self.apply(bind || null, args); - }; - }; - } - describe('Testing html-comments-parser $.fn.comments behavior', function () { var element, iframe, diff --git a/dev/tests/js/spec/integration/Magento/Ui/adminhtml/datepickerSpec.js b/dev/tests/js/spec/integration/Magento/Ui/adminhtml/datepickerSpec.js index bef0c0a93a2ebb1fa424818d81826a5a1c476c04..68e9566528e8d01d42aa3410da77e0bfbb85b81f 100644 --- a/dev/tests/js/spec/integration/Magento/Ui/adminhtml/datepickerSpec.js +++ b/dev/tests/js/spec/integration/Magento/Ui/adminhtml/datepickerSpec.js @@ -19,11 +19,11 @@ define([ $(document.body).append(element); - ko.applyBindingsToNode(element, { datepicker: observable }); + ko.applyBindingsToNode(element[0], { datepicker: observable }); }); afterEach(function () { - $(element).remove(); + element.remove(); }); it('writes picked date\'s value to assigned observable', function () { @@ -33,7 +33,7 @@ define([ dateFormat, result; - dateFormat = $(element).datepicker('option', 'dateFormat'); + dateFormat = element.datepicker('option', 'dateFormat'); todayDate = moment().format(dateFormat); openBtn = $('img.ui-datepicker-trigger'); diff --git a/dev/tests/js/spec/integration/config.js b/dev/tests/js/spec/integration/config.js deleted file mode 100644 index ade7f6387b1fb2ffa3a3d8d8d2bdf08b184a0029..0000000000000000000000000000000000000000 --- a/dev/tests/js/spec/integration/config.js +++ /dev/null @@ -1,6 +0,0 @@ -require.config({ - deps: [ - 'jquery/jquery', - 'underscore' - ] -}); \ No newline at end of file diff --git a/dev/tests/js/spec/integration/config/adminhtml.js b/dev/tests/js/spec/integration/config/adminhtml.js new file mode 100644 index 0000000000000000000000000000000000000000..50f98a25b682972761c774998c15442dbdd1c1b6 --- /dev/null +++ b/dev/tests/js/spec/integration/config/adminhtml.js @@ -0,0 +1,10 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +require.config({ + paths: { + 'jquery/ui': 'jquery/jquery-ui-1.9.2' + } +}); \ No newline at end of file diff --git a/dev/tests/js/spec/integration/config/frontend.js b/dev/tests/js/spec/integration/config/frontend.js new file mode 100644 index 0000000000000000000000000000000000000000..8791f57a90cfd289dbad10f5c140a34052b48139 --- /dev/null +++ b/dev/tests/js/spec/integration/config/frontend.js @@ -0,0 +1,10 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +require.config({ + paths: { + 'jquery/ui': 'jquery/jquery-ui' + } +}) \ No newline at end of file diff --git a/dev/tests/js/spec/require.config.js b/dev/tests/js/spec/require.config.js new file mode 100644 index 0000000000000000000000000000000000000000..f6f3838ed9032b332248b8ff540359df1429d424 --- /dev/null +++ b/dev/tests/js/spec/require.config.js @@ -0,0 +1,14 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +require.config({ + paths: { + 'ko': 'ko/ko', + 'domReady': 'requirejs/domReady' + }, + shim: { + 'jquery/ui': ['jquery'] + } +}); \ No newline at end of file diff --git a/dev/tests/js/spec/shim.js b/dev/tests/js/spec/shim.js new file mode 100644 index 0000000000000000000000000000000000000000..d816eb315da524431bc9db5d5f8cc3df6205d438 --- /dev/null +++ b/dev/tests/js/spec/shim.js @@ -0,0 +1,6 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +Function.prototype.bind=(function(){}).bind||function(b){if(typeof this!=="function"){throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");}function c(){}var a=[].slice,f=a.call(arguments,1),e=this,d=function(){return e.apply(this instanceof c?this:b||window,f.concat(a.call(arguments)));};c.prototype=this.prototype;d.prototype=new c();return d;}; \ No newline at end of file diff --git a/dev/tests/js/spec/unit/config.js b/dev/tests/js/spec/unit/config.js deleted file mode 100644 index ade7f6387b1fb2ffa3a3d8d8d2bdf08b184a0029..0000000000000000000000000000000000000000 --- a/dev/tests/js/spec/unit/config.js +++ /dev/null @@ -1,6 +0,0 @@ -require.config({ - deps: [ - 'jquery/jquery', - 'underscore' - ] -}); \ No newline at end of file diff --git a/dev/tests/js/spec/unit/config/adminhtml.js b/dev/tests/js/spec/unit/config/adminhtml.js new file mode 100644 index 0000000000000000000000000000000000000000..50f98a25b682972761c774998c15442dbdd1c1b6 --- /dev/null +++ b/dev/tests/js/spec/unit/config/adminhtml.js @@ -0,0 +1,10 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +require.config({ + paths: { + 'jquery/ui': 'jquery/jquery-ui-1.9.2' + } +}); \ No newline at end of file diff --git a/dev/tests/js/spec/unit/config/frontend.js b/dev/tests/js/spec/unit/config/frontend.js new file mode 100644 index 0000000000000000000000000000000000000000..8791f57a90cfd289dbad10f5c140a34052b48139 --- /dev/null +++ b/dev/tests/js/spec/unit/config/frontend.js @@ -0,0 +1,10 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +require.config({ + paths: { + 'jquery/ui': 'jquery/jquery-ui' + } +}) \ No newline at end of file