diff --git a/.travis.yml b/.travis.yml index ea6071b7b..4ddb3a185 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: node_js node_js: - 'node' # Latest stable Node.js release +env: + - ON_TRAVIS=true before_install: cd src before_script: - npm install -g grunt diff --git a/README.md b/README.md index 4701667eb..eb23a7efb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Lisk Nano [![Build Status](https://travis-ci.org/LiskHQ/lisk-nano.svg?branch=development)](https://travis-ci.org/LiskHQ/lisk-nano) +[![Coverage Status](https://coveralls.io/repos/github/LiskHQ/lisk-nano/badge.svg?branch=development)](https://coveralls.io/github/LiskHQ/lisk-nano?branch=development) ## Development diff --git a/src/app/index.js b/src/app/index.js index 57ca76e60..42f1cce52 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -1,34 +1,6 @@ -import 'jquery'; - -import 'angular'; -import 'angular-animate'; -import 'angular-cookies'; -import 'angular-aria'; -import 'angular-messages'; -import 'angular-material'; -import 'angular-material/angular-material.css'; -import 'angular-material-data-table/dist/md-data-table'; -import 'angular-material-data-table/dist/md-data-table.css'; - -import './index.less'; - -import './theme/theme'; -import './util/animateOnChange/animateOnChange'; -import './components/main/main'; -import './components/login/login'; -import './components/top/top'; -import './components/send/send'; -import './components/transactions/transactions'; -import './components/timestamp/timestamp'; -import './components/lsk/lsk'; - -import './services/peers/peers'; -import './services/lsk'; -import './services/success'; -import './services/error'; - -import './filters/lsk'; +import './libs'; +import './lisk-nano'; angular.element(document).ready(() => { angular.bootstrap(document, ['app']); diff --git a/src/app/libs.js b/src/app/libs.js new file mode 100644 index 000000000..cdcd5949a --- /dev/null +++ b/src/app/libs.js @@ -0,0 +1,13 @@ + +import 'jquery'; + +import 'angular'; +import 'angular-animate'; +import 'angular-cookies'; +import 'angular-aria'; +import 'angular-messages'; +import 'angular-material'; +import 'angular-material/angular-material.css'; +import 'angular-material-data-table/dist/md-data-table'; +import 'angular-material-data-table/dist/md-data-table.css'; + diff --git a/src/app/lisk-nano.js b/src/app/lisk-nano.js new file mode 100644 index 000000000..76203ee5c --- /dev/null +++ b/src/app/lisk-nano.js @@ -0,0 +1,18 @@ +import './index.less'; + +import './theme/theme'; +import './util/animateOnChange/animateOnChange'; +import './components/main/main'; +import './components/login/login'; +import './components/top/top'; +import './components/send/send'; +import './components/transactions/transactions'; +import './components/timestamp/timestamp'; +import './components/lsk/lsk'; + +import './services/peers/peers'; +import './services/lsk'; +import './services/success'; +import './services/error'; + +import './filters/lsk'; diff --git a/src/karma.conf.js b/src/karma.conf.js index b1f0d90af..66a1f776c 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -4,9 +4,16 @@ var webpackConfig = require('./webpack.config.babel'); var preprocessors = {}; //preprocessors[entry] = ['webpack']; preprocessors['**/*.html'] = ['ng-html2js']; +var libs = path.join(__dirname, 'app', 'libs.js'); +var app = path.join(__dirname, 'app', 'lisk-nano.js'); var test = path.join(__dirname, 'test', 'test.js'); +preprocessors[libs] = ['webpack']; +preprocessors[app] = ['webpack', 'coverage']; preprocessors[test] = ['webpack']; -preprocessors['app/**/*.js'] = ['coverage']; + +var opts = { + onTravis: process.env.ON_TRAVIS, +}; module.exports = function(config) { config.set({ @@ -19,7 +26,7 @@ module.exports = function(config) { frameworks: ['mocha', 'chai'], // list of files / patterns to load in the browser - files: [test], + files: [libs, app, test], webpack: webpackConfig, // list of files to exclude @@ -28,7 +35,7 @@ module.exports = function(config) { // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress', 'coverage'], + reporters: ['progress', 'mocha', 'coverage'].concat(opts.onTravis ? ['coveralls'] : []), preprocessors: preprocessors, @@ -57,11 +64,10 @@ module.exports = function(config) { moduleName: 'my.templates' }, - reporters: ['mocha'], coverageReporter: { - type : 'html', - dir : 'coverage/' + type : opts.onTravis ? 'lcov' : 'text', + dir : 'coverage/', }, @@ -87,6 +93,7 @@ module.exports = function(config) { 'karma-ng-html2js-preprocessor', 'karma-mocha-reporter', 'karma-coverage', + 'karma-coveralls', 'karma-phantomjs-launcher' ] }); diff --git a/src/package.json b/src/package.json index b1b4b6707..619804cac 100644 --- a/src/package.json +++ b/src/package.json @@ -28,6 +28,7 @@ "babel-core": "=6.9.1", "babel-loader": "=6.2.4", "babel-plugin-syntax-trailing-function-commas": "=6.22.0", + "babel-plugin-istanbul": "^4.0.0", "babel-polyfill": "=6.9.1", "babel-preset-es2015": "=6.9.0", "chai": "=3.5.0", @@ -50,6 +51,7 @@ "karma-chai": "=0.1.0", "karma-chrome-launcher": "=2.0.0", "karma-coverage": "^1.1.1", + "karma-coveralls": "^1.1.2", "karma-mocha": "=1.3.0", "karma-mocha-reporter": "=2.2.2", "karma-ng-html2js-preprocessor": "=1.0.0", @@ -79,6 +81,13 @@ "presets": [ "es2015" ], - "plugins": ["syntax-trailing-function-commas"] + "plugins": ["syntax-trailing-function-commas"], + "env": { + "test": { + "plugins": [ + "istanbul" + ] + } + } } } diff --git a/src/test/components/login/login.spec.js b/src/test/components/login/login.spec.js new file mode 100644 index 000000000..ae31f9289 --- /dev/null +++ b/src/test/components/login/login.spec.js @@ -0,0 +1,23 @@ +describe('Login component', function() { + var $compile, + $rootScope; + + // Load the myApp module, which contains the directive + beforeEach(angular.mock.module("app")); + + // Store references to $rootScope and $compile + // so they are available to all tests in this describe block + beforeEach(inject(function(_$compile_, _$rootScope_){ + // The injector unwraps the underscores (_) from around the parameter names when matching + $compile = _$compile_; + $rootScope = _$rootScope_; + })); + + it('should contain header', function() { + // Compile a piece of HTML containing the directive + var element = $compile("")($rootScope); + $rootScope.$digest(); + expect(element.html()).to.contain("Sign In"); + }); +}); + diff --git a/src/test/components/top/top.spec.js b/src/test/components/top/top.spec.js index 8d96e5adc..6a0cebd6f 100644 --- a/src/test/components/top/top.spec.js +++ b/src/test/components/top/top.spec.js @@ -1,4 +1,3 @@ -var expect = require('chai').expect; describe('Top component', function() { var $compile, diff --git a/src/test/test.js b/src/test/test.js index 2832d6709..39d45b3f6 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -1,6 +1,7 @@ -require('../app'); require('angular-mocks/angular-mocks'); +require('chai'); +require('./components/login/login.spec'); require('./components/top/top.spec');