From 6f1b60e5627f985bc3203c003ce7127278513b75 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Fri, 21 Mar 2014 18:45:59 -0300 Subject: [PATCH] added karma test framework and network skeleton --- .gitignore | 2 ++ bower.json | 8 ++++- index.html | 1 + js/network.js | 7 +++++ karma.conf.js | 72 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 6 +++- test/test.html | 29 ++++++++++++++++++ test/test.network.js | 21 +++++++++++++ 8 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 js/network.js create mode 100644 karma.conf.js create mode 100644 test/test.html create mode 100644 test/test.network.js diff --git a/.gitignore b/.gitignore index 896506df6..48dd0ca77 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,5 @@ public/js/vendors.js public/css/main.css README.html + +lib diff --git a/bower.json b/bower.json index 3d5bc6395..b3c17df64 100644 --- a/bower.json +++ b/bower.json @@ -8,6 +8,12 @@ "dependencies": { "angular": "~1.2.x", "angular-bootstrap": "~0.10.0", - "angular-route": "~1.2.14" + "angular-route": "~1.2.14", + "peerjs": "~0.3.8", + "angular-mocks": "~1.2.14" + }, + "devDependencies": { + "mocha": "~1.18.2", + "chai": "~1.9.1" } } diff --git a/index.html b/index.html index c6e0bce88..a42ce0ba0 100644 --- a/index.html +++ b/index.html @@ -33,6 +33,7 @@ + diff --git a/js/network.js b/js/network.js new file mode 100644 index 000000000..4e0ebcb16 --- /dev/null +++ b/js/network.js @@ -0,0 +1,7 @@ + +var cosign = angular.module('cosign', []); +cosign.service('network', function() { + this.f = function() { + return 2; + }; +}); diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 000000000..3de26ae16 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,72 @@ +// Karma configuration +// Generated on Fri Mar 21 2014 17:52:41 GMT-0300 (ART) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['mocha'], + + + // list of files / patterns to load in the browser + files: [ + 'lib/angular/angular.min.js', + 'lib/angular-mocks/angular-mocks.js', + 'lib/chai/chai.js', + 'js/*.js', + 'js/**/*.js', + 'test/test*.js', + ], + + + // list of files to exclude + exclude: [ + + ], + + + // 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 + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: [], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }); +}; diff --git a/package.json b/package.json index a2fe752e4..bac19d810 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,10 @@ }, "homepage": "https://github.com/bitpay/cosign", "devDependencies": { - "grunt-cli": "~0.1.13" + "grunt-cli": "~0.1.13", + "karma": "~0.12.1", + "karma-chrome-launcher": "~0.1.2", + "mocha": "~1.18.2", + "karma-mocha": "~0.1.3" } } diff --git a/test/test.html b/test/test.html new file mode 100644 index 000000000..eddef6100 --- /dev/null +++ b/test/test.html @@ -0,0 +1,29 @@ + + + + + Cosign tests + + + +
+
+
+ + + + + + + + + + + + + + + + + + diff --git a/test/test.network.js b/test/test.network.js new file mode 100644 index 000000000..dce8c0eaf --- /dev/null +++ b/test/test.network.js @@ -0,0 +1,21 @@ +'use strict'; + +var should = chai.should(); +describe('Network service', function() { + + var network; + beforeEach(angular.mock.module('cosign')); + + it('should exist', function() { + inject(function($injector) { + network = $injector.get('network'); + should.exist(network); + }); + }); + it('should return 2', function() { + network.f().should.equal(2); + }); + it('should', function() {}); + it('should', function() {}); + +});