Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #67 from LiskHQ/51_test-coverage
Browse files Browse the repository at this point in the history
Adding test coverage metric that works with Angular - Closes #51
  • Loading branch information
karmacoma authored Mar 21, 2017
2 parents d5f59e2 + 480c92f commit d0c8c38
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
32 changes: 2 additions & 30 deletions src/app/index.js
Original file line number Diff line number Diff line change
@@ -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']);
Expand Down
13 changes: 13 additions & 0 deletions src/app/libs.js
Original file line number Diff line number Diff line change
@@ -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';

18 changes: 18 additions & 0 deletions src/app/lisk-nano.js
Original file line number Diff line number Diff line change
@@ -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';
19 changes: 13 additions & 6 deletions src/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
Expand All @@ -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,

Expand Down Expand Up @@ -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/',
},


Expand All @@ -87,6 +93,7 @@ module.exports = function(config) {
'karma-ng-html2js-preprocessor',
'karma-mocha-reporter',
'karma-coverage',
'karma-coveralls',
'karma-phantomjs-launcher'
]
});
Expand Down
11 changes: 10 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -79,6 +81,13 @@
"presets": [
"es2015"
],
"plugins": ["syntax-trailing-function-commas"]
"plugins": ["syntax-trailing-function-commas"],
"env": {
"test": {
"plugins": [
"istanbul"
]
}
}
}
}
23 changes: 23 additions & 0 deletions src/test/components/login/login.spec.js
Original file line number Diff line number Diff line change
@@ -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("<login></login>")($rootScope);
$rootScope.$digest();
expect(element.html()).to.contain("Sign In");
});
});

1 change: 0 additions & 1 deletion src/test/components/top/top.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var expect = require('chai').expect;

describe('Top component', function() {
var $compile,
Expand Down
3 changes: 2 additions & 1 deletion src/test/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require('../app');

require('angular-mocks/angular-mocks');
require('chai');

require('./components/login/login.spec');
require('./components/top/top.spec');

0 comments on commit d0c8c38

Please sign in to comment.