diff --git a/Gemfile b/Gemfile index 1199045f2..c45dca6b3 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,8 @@ group :development, :test do gem 'puma' + gem 'haml' + # Deployment tools gem 'capistrano' gem 'capistrano-bundler' diff --git a/README.md b/README.md index 7a42d648f..34ddeb294 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ This web app is available on https://app.standardnotes.org. For more information on Standard Notes, see https://standardnotes.org. +[![CI](https://circleci.com/gh/standardnotes/web.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/standardnotes/web) + ## Features - Grouping of notes diff --git a/circle.yml b/circle.yml new file mode 100644 index 000000000..b6b7654cb --- /dev/null +++ b/circle.yml @@ -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 diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 000000000..c5e272a90 --- /dev/null +++ b/karma.conf.js @@ -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 + }) +} diff --git a/package.json b/package.json index 58902c563..ef0acd98d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,12 @@ { "name": "neeto", "version": "1.0.0", + "scripts": { + "test": "karma start karma.conf.js --single-run" + }, "devDependencies": { + "angular": "^1.6.1", + "angular-mocks": "^1.6.1", "babel-cli": "^6.18.0", "babel-preset-env": "^1.1.1", "babel-preset-es2016": "^6.16.0", @@ -16,6 +21,11 @@ "grunt-contrib-watch": "^1.0.0", "grunt-haml2html": "^0.3.1", "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" } } diff --git a/test/javascripts/controllers/HomeCtrl_spec.js b/test/javascripts/controllers/HomeCtrl_spec.js new file mode 100644 index 000000000..a44ae7e93 --- /dev/null +++ b/test/javascripts/controllers/HomeCtrl_spec.js @@ -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"); + }); + + }); + +}); diff --git a/test/javascripts/filters/DateFilter_spec.js b/test/javascripts/filters/DateFilter_spec.js new file mode 100644 index 000000000..b79c1dce9 --- /dev/null +++ b/test/javascripts/filters/DateFilter_spec.js @@ -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(); + }); + +});