diff --git a/Brocfile.js b/Brocfile.js index fe818ec602..37408d022f 100644 --- a/Brocfile.js +++ b/Brocfile.js @@ -20,6 +20,7 @@ var args = parseArgs(allArgs['--']); var shouldCompress = isUndefined(args.compress) ? false : args.compress; var debugMode = isUndefined(args.debug) ? false : args.debug; var silentMode = isUndefined(args.silent) ? false : args.silent; +var includeTests = isUndefined(args.tests) ? true : args.tests; var appName = 'tower'; @@ -67,6 +68,11 @@ var vendorFiles = 'ansible/*.js' ]; +var testFiles = + [ 'tests/helpers.js', + 'tests/unit/**/*.js' + ]; + function log() { var msgs = Array.prototype.slice.apply(arguments); @@ -133,6 +139,18 @@ var styles = compileLess(appStyles, 'less/ansible-ui.less', 'tower.min.css'); app = mergeTrees([app, styles]); +if (includeTests) { + var tests = new Funnel('awx/ui', + { include: ['tests/unit/**/*.js'] + + }); + + tests = doDebug('tests-funnel', tests); + tests = new ES6(tests); + app = mergeTrees([app, tests]); + app = doDebug('merge-tests', app); +} + if (shouldCompress) { app = uglifyFiles(app); app = gzip(app, diff --git a/awx/ui/static/lib/ember-cli-test-loader/.bower.json b/awx/ui/static/lib/ember-cli-test-loader/.bower.json new file mode 100644 index 0000000000..f6ec16638f --- /dev/null +++ b/awx/ui/static/lib/ember-cli-test-loader/.bower.json @@ -0,0 +1,33 @@ +{ + "name": "ember-cli-test-loader", + "main": "test-loader.js", + "version": "0.1.0", + "homepage": "https://github.com/rjackson/ember-cli-test-loader", + "description": "Test loader for Ember CLI projects.", + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "authors": [ + "Robert Jackson " + ], + "moduleType": [ + "globals" + ], + "keywords": [ + "ember-cli" + ], + "_release": "0.1.0", + "_resolution": { + "type": "version", + "tag": "v0.1.0", + "commit": "c6006a11515c756d115bb5209103a22c2e9554a0" + }, + "_source": "git://github.com/ember-cli/ember-cli-test-loader.git", + "_target": "0.1.0", + "_originalSource": "ember-cli/ember-cli-test-loader" +} \ No newline at end of file diff --git a/awx/ui/static/lib/ember-cli-test-loader/README.md b/awx/ui/static/lib/ember-cli-test-loader/README.md new file mode 100644 index 0000000000..ce17d9a9f9 --- /dev/null +++ b/awx/ui/static/lib/ember-cli-test-loader/README.md @@ -0,0 +1,19 @@ +## Ember CLI Test Loader + +Defines a `TestLoader` object that reviews all of the modules in +`requirejs.entries` and loads those identified as tests. + +`TestLoader.prototype.shouldLoadModule` can be overridden in order to customize +the criteria for identifying test modules. + +### Usage + +Within your test suite: + +```javascript + var TestLoader = require('ember-cli/test-loader')['default']; + + // optionally override TestLoader.prototype.shouldLoadModule + + TestLoader.load(); +``` diff --git a/awx/ui/static/lib/ember-cli-test-loader/bower.json b/awx/ui/static/lib/ember-cli-test-loader/bower.json new file mode 100644 index 0000000000..59e977ecb6 --- /dev/null +++ b/awx/ui/static/lib/ember-cli-test-loader/bower.json @@ -0,0 +1,24 @@ +{ + "name": "ember-cli-test-loader", + "main": "test-loader.js", + "version": "0.1.0", + "homepage": "https://github.com/rjackson/ember-cli-test-loader", + "description": "Test loader for Ember CLI projects.", + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "authors": [ + "Robert Jackson " + ], + "moduleType": [ + "globals" + ], + "keywords": [ + "ember-cli" + ] +} diff --git a/awx/ui/static/lib/ember-cli-test-loader/test-loader.js b/awx/ui/static/lib/ember-cli-test-loader/test-loader.js new file mode 100644 index 0000000000..4cd5b31be9 --- /dev/null +++ b/awx/ui/static/lib/ember-cli-test-loader/test-loader.js @@ -0,0 +1,36 @@ +/* globals requirejs, require */ +(function() { +define("ember-cli/test-loader", + [], + function() { + "use strict"; + + var TestLoader = function() { + }; + + TestLoader.prototype = { + shouldLoadModule: function(moduleName) { + return (moduleName.match(/[-_]test$/)); + }, + + loadModules: function() { + var moduleName; + + for (moduleName in requirejs.entries) { + if (this.shouldLoadModule(moduleName)) { + require(moduleName); + } + } + } + }; + + TestLoader.load = function() { + new TestLoader().loadModules(); + }; + + return { + 'default': TestLoader + } + } +); +})(); diff --git a/awx/ui/tests/karma.conf.js b/awx/ui/tests/karma.conf.js index e4c75001eb..c3953ade0c 100644 --- a/awx/ui/tests/karma.conf.js +++ b/awx/ui/tests/karma.conf.js @@ -10,53 +10,13 @@ module.exports = function(config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha', 'chai', 'sinon-chai', 'chai-as-promised'], - // list of files / patterns to load in the browser files: [ - '../static/lib/jquery/dist/jquery.min.js', - '../static/lib/angular/angular.js', - '../static/lib/angular-route/angular-route.js', - '../static/lib/angular-resource/angular-resource.js', - '../static/lib/angular-cookies/angular-cookies.js', - '../static/lib/angular-sanitize/angular-sanitize.min.js', - '../static/lib/angular-md5/angular-md5.min.js', - '../static/lib/angular-codemirror/lib/AngularCodeMirror.js', - '../static/lib/timezone-js/src/date.js', - '../static/lib/angular-tz-extensions/packages/jstimezonedetect/jstz.min.js', - '../static/lib/underscore/underscore.js', - '../static/lib/rrule/lib/rrule.js', - '../static/lib/rrule/lib/nlp.js', - '../static/lib/angular-tz-extensions/lib/angular-tz-extensions.js', - '../static/lib/angular-scheduler/lib/angular-scheduler.min.js', - '../static/lib/jqueryui/ui/minified/jquery-ui.min.js', - '../static/lib/bootstrap/dist/js/bootstrap.min.js', - '../static/lib/js-yaml/dist/js-yaml.min.js', - '../static/lib/select2/select2.min.js', - '../static/lib/jsonlint/lib/jsonlint.js', - '../static/lib/codemirror/lib/codemirror.js', - '../static/lib/codemirror/mode/javascript/javascript.js', - '../static/lib/codemirror/mode/yaml/yaml.js', - '../static/lib/codemirror/addon/lint/lint.js', - '../static/lib/codemirror/addon/lint/json-lint.js', - '../static/lib/angular-codemirror/lib/yaml-lint.js', - '../static/lib/codemirror/addon/edit/closebrackets.js', - '../static/lib/codemirror/addon/edit/matchbrackets.js', - '../static/lib/codemirror/addon/selection/active-line.js', - '../static/lib/scrollto/lib/jquery-scrollto.js', - '../static/lib/socket.io-client/dist/socket.io.min.js', - '../static/lib/d3js/build/d3.v3.min.js', - '../static/lib/novus-nvd3/nv.d3.min.js', - '../static/lib/d3Donut/d3Donut.js', - '../static/lib/jPushMenu/jPushMenu.js', - '../static/lib/lrInfiniteScroll/lrInfiniteScroll.js', - '../static/lib/ansible/*.js', - '../static/js/config.js', - '../static/js/directives/_dashboard-graphs.js', - '../static/js/*/*.js', - '../static/js/app.js', - '../static/lib/angular-mocks/angular-mocks.js', - './unit/*', - './unit/**/*' + '../static/dist/tower.concat.js', + '../static/lib/angular-mocks/angular-mocks.js', + '../static/lib/ember-cli-test-loader/test-loader.js', + '../static/dist/tests/**/*.js', + '../tests/unit.js' ], @@ -66,12 +26,6 @@ module.exports = function(config) { ], - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - }, - - // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter diff --git a/awx/ui/tests/unit.js b/awx/ui/tests/unit.js new file mode 100644 index 0000000000..005cbb49ad --- /dev/null +++ b/awx/ui/tests/unit.js @@ -0,0 +1,6 @@ +window.$AnsibleConfig = null; +window.$basePath = '/static/'; + +var testLoader = require('ember-cli/test-loader'); + +testLoader.default.load(); diff --git a/awx/ui/tests/unit/directives/job-status-graph-test.js b/awx/ui/tests/unit/directives/job-status-graph-test.js index 18f5596916..c70423d6cb 100644 --- a/awx/ui/tests/unit/directives/job-status-graph-test.js +++ b/awx/ui/tests/unit/directives/job-status-graph-test.js @@ -1,3 +1,5 @@ +import Tower from 'tower/app'; + describe('Job Status Graph Directive', function() { var element, scope, httpBackend;