From b951bec682b8e10f29394dec1bd246a65ce47a34 Mon Sep 17 00:00:00 2001 From: psychowood Date: Tue, 16 Dec 2014 18:01:53 +0100 Subject: [PATCH] Skeleton for test Still not used and excluded from the build --- .gitignore | 1 - test/.jshintrc | 36 ++++++++++++ test/karma.conf.js | 75 +++++++++++++++++++++++++ test/spec/controllers/about.js | 22 ++++++++ test/spec/controllers/details-dialog.js | 22 ++++++++ test/spec/controllers/main.js | 22 ++++++++ test/spec/controllers/settings.js | 22 ++++++++ test/spec/directives/torrent-status.js | 20 +++++++ test/spec/services/utorrentservice.js | 18 ++++++ 9 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 test/.jshintrc create mode 100644 test/karma.conf.js create mode 100644 test/spec/controllers/about.js create mode 100644 test/spec/controllers/details-dialog.js create mode 100644 test/spec/controllers/main.js create mode 100644 test/spec/controllers/settings.js create mode 100644 test/spec/directives/torrent-status.js create mode 100644 test/spec/services/utorrentservice.js diff --git a/.gitignore b/.gitignore index d953ed4..a4abeaf 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ dist .tmp .sass-cache bower_components -test releases diff --git a/test/.jshintrc b/test/.jshintrc new file mode 100644 index 0000000..b1be025 --- /dev/null +++ b/test/.jshintrc @@ -0,0 +1,36 @@ +{ + "node": true, + "browser": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": true, + "newcap": true, + "noarg": true, + "quotmark": "single", + "regexp": true, + "undef": true, + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true, + "globals": { + "after": false, + "afterEach": false, + "angular": false, + "before": false, + "beforeEach": false, + "browser": false, + "describe": false, + "expect": false, + "inject": false, + "it": false, + "jasmine": false, + "spyOn": false + } +} + diff --git a/test/karma.conf.js b/test/karma.conf.js new file mode 100644 index 0000000..9efa2b3 --- /dev/null +++ b/test/karma.conf.js @@ -0,0 +1,75 @@ +// Karma configuration +// http://karma-runner.github.io/0.12/config/configuration-file.html +// Generated on 2014-10-17 using +// generator-karma 0.8.3 + +module.exports = function(config) { + 'use strict'; + + config.set({ + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + // base path, that will be used to resolve files and exclude + basePath: '../', + + // testing framework to use (jasmine/mocha/qunit/...) + frameworks: ['jasmine'], + + // list of files / patterns to load in the browser + files: [ + 'bower_components/angular/angular.js', + 'bower_components/angular-mocks/angular-mocks.js', + 'bower_components/angular-animate/angular-animate.js', + 'bower_components/angular-cookies/angular-cookies.js', + 'bower_components/angular-resource/angular-resource.js', + 'bower_components/angular-route/angular-route.js', + 'bower_components/angular-sanitize/angular-sanitize.js', + 'bower_components/angular-touch/angular-touch.js', + 'app/scripts/**/*.js', + 'test/mock/**/*.js', + 'test/spec/**/*.js' + ], + + // list of files / patterns to exclude + exclude: [], + + // web server port + port: 8080, + + // Start these browsers, currently available: + // - Chrome + // - ChromeCanary + // - Firefox + // - Opera + // - Safari (only Mac) + // - PhantomJS + // - IE (only Windows) + browsers: [ + 'PhantomJS' + ], + + // Which plugins to enable + plugins: [ + 'karma-phantomjs-launcher', + 'karma-jasmine' + ], + + // Continuous Integration mode + // if true, it capture browsers, run tests and exit + singleRun: false, + + colors: true, + + // level of logging + // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG + logLevel: config.LOG_INFO, + + // Uncomment the following lines if you are using grunt's server to run the tests + // proxies: { + // '/': 'http://localhost:9000/' + // }, + // URL root prevent conflicts with the site root + // urlRoot: '_karma_' + }); +}; diff --git a/test/spec/controllers/about.js b/test/spec/controllers/about.js new file mode 100644 index 0000000..574507c --- /dev/null +++ b/test/spec/controllers/about.js @@ -0,0 +1,22 @@ +'use strict'; + +describe('Controller: AboutCtrl', function () { + + // load the controller's module + beforeEach(module('utorrentNgwebuiApp')); + + var AboutCtrl, + scope; + + // Initialize the controller and a mock scope + beforeEach(inject(function ($controller, $rootScope) { + scope = $rootScope.$new(); + AboutCtrl = $controller('AboutCtrl', { + $scope: scope + }); + })); + + it('should attach a list of awesomeThings to the scope', function () { + expect(scope.awesomeThings.length).toBe(3); + }); +}); diff --git a/test/spec/controllers/details-dialog.js b/test/spec/controllers/details-dialog.js new file mode 100644 index 0000000..3228f1d --- /dev/null +++ b/test/spec/controllers/details-dialog.js @@ -0,0 +1,22 @@ +'use strict'; + +describe('Controller: DetailsDialogCtrl', function () { + + // load the controller's module + beforeEach(module('ngTorrentUiApp')); + + var DetailsDialogCtrl, + scope; + + // Initialize the controller and a mock scope + beforeEach(inject(function ($controller, $rootScope) { + scope = $rootScope.$new(); + DetailsDialogCtrl = $controller('DetailsDialogCtrl', { + $scope: scope + }); + })); + + it('should attach a list of awesomeThings to the scope', function () { + expect(scope.awesomeThings.length).toBe(3); + }); +}); diff --git a/test/spec/controllers/main.js b/test/spec/controllers/main.js new file mode 100644 index 0000000..80e449c --- /dev/null +++ b/test/spec/controllers/main.js @@ -0,0 +1,22 @@ +'use strict'; + +describe('Controller: MainCtrl', function () { + + // load the controller's module + beforeEach(module('utorrentNgwebuiApp')); + + var MainCtrl, + scope; + + // Initialize the controller and a mock scope + beforeEach(inject(function ($controller, $rootScope) { + scope = $rootScope.$new(); + MainCtrl = $controller('MainCtrl', { + $scope: scope + }); + })); + + it('should attach a list of awesomeThings to the scope', function () { + expect(scope.awesomeThings.length).toBe(3); + }); +}); diff --git a/test/spec/controllers/settings.js b/test/spec/controllers/settings.js new file mode 100644 index 0000000..3fa94f8 --- /dev/null +++ b/test/spec/controllers/settings.js @@ -0,0 +1,22 @@ +'use strict'; + +describe('Controller: SettingsCtrl', function () { + + // load the controller's module + beforeEach(module('utorrentNgwebuiApp')); + + var SettingsCtrl, + scope; + + // Initialize the controller and a mock scope + beforeEach(inject(function ($controller, $rootScope) { + scope = $rootScope.$new(); + SettingsCtrl = $controller('SettingsCtrl', { + $scope: scope + }); + })); + + it('should attach a list of awesomeThings to the scope', function () { + expect(scope.awesomeThings.length).toBe(3); + }); +}); diff --git a/test/spec/directives/torrent-status.js b/test/spec/directives/torrent-status.js new file mode 100644 index 0000000..bc2ec18 --- /dev/null +++ b/test/spec/directives/torrent-status.js @@ -0,0 +1,20 @@ +'use strict'; + +describe('Directive: torrentStatus', function () { + + // load the directive's module + beforeEach(module('utorrentNgwebuiApp')); + + var element, + scope; + + beforeEach(inject(function ($rootScope) { + scope = $rootScope.$new(); + })); + + it('should make hidden element visible', inject(function ($compile) { + element = angular.element(''); + element = $compile(element)(scope); + expect(element.text()).toBe('this is the torrentStatus directive'); + })); +}); diff --git a/test/spec/services/utorrentservice.js b/test/spec/services/utorrentservice.js new file mode 100644 index 0000000..90e2b85 --- /dev/null +++ b/test/spec/services/utorrentservice.js @@ -0,0 +1,18 @@ +'use strict'; + +describe('Service: uTorrentService', function () { + + // load the service's module + beforeEach(module('utorrentNgwebuiApp')); + + // instantiate service + var uTorrentService; + beforeEach(inject(function (_uTorrentService_) { + uTorrentService = _uTorrentService_; + })); + + it('should do something', function () { + expect(!!uTorrentService).toBe(true); + }); + +});