First pass at testing
- Unit/Integration(ish) tests for Home Controller - Simple test for the date filter - Dependencies for Karma and Jasmine - circle.yml file for CI
This commit is contained in:
20
circle.yml
Normal file
20
circle.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
machine:
|
||||||
|
ruby:
|
||||||
|
version:
|
||||||
|
2.3.1
|
||||||
|
node:
|
||||||
|
version:
|
||||||
|
6.1.0
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
pre:
|
||||||
|
- npm install -g grunt
|
||||||
|
override:
|
||||||
|
- bundle install
|
||||||
|
- npm install
|
||||||
|
- bundle exec rake bower:install
|
||||||
|
- grunt
|
||||||
|
|
||||||
|
test:
|
||||||
|
override:
|
||||||
|
- npm test
|
||||||
72
karma.conf.js
Normal file
72
karma.conf.js
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
// Karma configuration
|
||||||
|
// Generated on Thu Jan 19 2017 22:15:55 GMT-0800 (PST)
|
||||||
|
|
||||||
|
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: ['jasmine'],
|
||||||
|
|
||||||
|
|
||||||
|
// list of files / patterns to load in the browser
|
||||||
|
files: [
|
||||||
|
'vendor/assets/bower_components/angular/angular.js',
|
||||||
|
'node_modules/angular-mocks/angular-mocks.js',
|
||||||
|
'vendor/assets/javascripts/compiled.js',
|
||||||
|
'test/javascripts/**/*_spec.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_ERROR,
|
||||||
|
|
||||||
|
|
||||||
|
// 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: ['PhantomJS'],
|
||||||
|
|
||||||
|
|
||||||
|
// Continuous Integration mode
|
||||||
|
// if true, Karma captures browsers, runs the tests and exits
|
||||||
|
singleRun: false,
|
||||||
|
|
||||||
|
// Concurrency level
|
||||||
|
// how many browser should be started simultaneous
|
||||||
|
concurrency: Infinity
|
||||||
|
})
|
||||||
|
}
|
||||||
12
package.json
12
package.json
@@ -1,7 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "neeto",
|
"name": "neeto",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"test": "karma start karma.conf.js --single-run"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"angular": "^1.6.1",
|
||||||
|
"angular-mocks": "^1.6.1",
|
||||||
"babel-cli": "^6.18.0",
|
"babel-cli": "^6.18.0",
|
||||||
"babel-preset-env": "^1.1.1",
|
"babel-preset-env": "^1.1.1",
|
||||||
"babel-preset-es2016": "^6.16.0",
|
"babel-preset-es2016": "^6.16.0",
|
||||||
@@ -16,6 +21,11 @@
|
|||||||
"grunt-contrib-watch": "^1.0.0",
|
"grunt-contrib-watch": "^1.0.0",
|
||||||
"grunt-haml2html": "^0.3.1",
|
"grunt-haml2html": "^0.3.1",
|
||||||
"grunt-newer": "^1.2.0",
|
"grunt-newer": "^1.2.0",
|
||||||
"grunt-ng-annotate": "^3.0.0"
|
"grunt-ng-annotate": "^3.0.0",
|
||||||
|
"jasmine": "^2.5.3",
|
||||||
|
"karma": "^1.4.0",
|
||||||
|
"karma-cli": "^1.0.1",
|
||||||
|
"karma-jasmine": "^1.1.0",
|
||||||
|
"karma-phantomjs-launcher": "^1.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
37
test/javascripts/controllers/HomeCtrl_spec.js
Normal file
37
test/javascripts/controllers/HomeCtrl_spec.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
describe("app.frontend", function() {
|
||||||
|
|
||||||
|
beforeEach(module('app.frontend'));
|
||||||
|
|
||||||
|
describe('Home Controller', function() {
|
||||||
|
|
||||||
|
var scope;
|
||||||
|
beforeEach(inject(function($rootScope, $controller, modelManager) {
|
||||||
|
scope = $rootScope.$new();
|
||||||
|
$modelManager = modelManager;
|
||||||
|
$controller("HomeCtrl", {
|
||||||
|
$scope: scope,
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should have a body class', function() {
|
||||||
|
expect(scope.bodyClass).toEqual('app-body-class');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have an All tag', function() {
|
||||||
|
expect(scope.allTag).toBeDefined();
|
||||||
|
expect(scope.allTag.title).toEqual("All");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have notes and tags model managers', function() {
|
||||||
|
expect($modelManager.tags).toBeDefined();
|
||||||
|
expect($modelManager.notes).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to add a new tag', function() {
|
||||||
|
scope.tagsAddNew("testTag");
|
||||||
|
expect($modelManager.items).toContain("testTag");
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
19
test/javascripts/filters/DateFilter_spec.js
Normal file
19
test/javascripts/filters/DateFilter_spec.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
describe("date filter", function() {
|
||||||
|
beforeEach(module('app.frontend'));
|
||||||
|
var $filter;
|
||||||
|
|
||||||
|
beforeEach(inject(function(_$filter_){
|
||||||
|
$filter = _$filter_;
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('returns a defined time', function() {
|
||||||
|
var date = $filter('appDate');
|
||||||
|
expect(date(Date())).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns time', function() {
|
||||||
|
var dateTime = $filter('appDateTime');
|
||||||
|
expect(dateTime(Date())).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user