Commit f465d231 authored by George Batalinski's avatar George Batalinski Committed by Valentin Hervieu

setup tests

parent 4ebb630c
module.exports = function(grunt) {
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
minBanner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'(c) <%= pkg.author %>, <%= pkg.repository.url %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */\n',
'(c) <%= pkg.author %>, <%= pkg.repository.url %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */\n',
recess: {
options: {
......@@ -58,10 +58,10 @@ module.exports = function(grunt) {
removeStyleLinkTypeAttributes: true
},
module: 'rzModule',
url: function(url) {
url: function (url) {
return url.replace('src/', '');
},
bootstrap: function(module, script) {
bootstrap: function (module, script) {
return 'module.run(function($templateCache) {\n' + script + '\n});';
}
}
......@@ -118,8 +118,13 @@ module.exports = function(grunt) {
options: {
port: 9000
}
},
karma: {
unit: {
configFile: 'karma.conf.js',
singleRun: true
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
......@@ -129,8 +134,10 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-ng-annotate');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-serve');
grunt.loadNpmTasks('grunt-karma');
grunt.registerTask('default', ['css', 'js']);
grunt.registerTask('test', ['karma']);
grunt.registerTask('css', ['recess']);
grunt.registerTask('js', ['ngtemplates', 'replace', 'ngAnnotate', 'uglify']);
......
'use strict';
module.exports = function (config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['mocha', 'chai', 'chai-things', 'chai-as-promised'],
// list of files / patterns to load in the browser
files: [
'bower_components/angular/angular.js',
'node_modules/angular-mocks/angular-mocks.js',
'src/*.js',
'tests/spec/*.js',
'src/*.html'
],
// list of files / patterns to exclude
exclude: [],
// preprocess matching files before serving them to the browser
preprocessors: {
"src/*Tpl.html": 'ng-html2js'
},
ngHtml2JsPreprocessor: {
stripPrefix: 'src/',
moduleName: 'appTemplates'
},
// web server port
port: 9998,
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
})
;
}
;
......@@ -12,15 +12,28 @@
"slider"
],
"devDependencies": {
"angular-mocks": "^1.4.8",
"chai": "^3.4.1",
"chai-as-promised": "^5.1.0",
"chai-things": "^0.2.0",
"grunt": "~0.4.2",
"grunt-angular-templates": "^0.5.7",
"grunt-contrib-mincss": "~0.3.2",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "^0.6.1",
"grunt-karma": "^0.12.1",
"grunt-ng-annotate": "^1.0.1",
"grunt-recess": "~0.4.0",
"grunt-replace": "^0.11.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-serve": "^0.1.6",
"karma": "^0.13.15",
"karma-chai-plugins": "^0.6.1",
"karma-chrome-launcher": "^0.2.2",
"karma-mocha": "^0.2.1",
"karma-ng-html2js-preprocessor": "^0.2.0",
"karma-phantomjs-launcher": "^0.2.1",
"mocha": "^2.3.4",
"phantomjs": "^1.9.19",
"recess": "~1.1.9"
},
"author": "Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com>",
......
'use strict';
describe('rzslider api', function () {
var RzSlider;
var $rootScope;
var scope;
var $compile;
var element;
var $httpBackend;
beforeEach(module('rzModule'));
beforeEach(module('appTemplates'));
beforeEach(inject(function (_RzSlider_, _$rootScope_, _$compile_, _$httpBackend_) {
RzSlider = _RzSlider_;
$rootScope = _$rootScope_;
$compile = _$compile_;
$httpBackend = _$httpBackend_;
}));
it('should exist compiled', function () {
scope = $rootScope.$new();
scope.minSlider = {
value: 10
};
element = $compile("<rzslider rz-slider-model='minSlider.value'></rzslider>")($rootScope);
$rootScope.$digest();
expect(element.find('span')).to.have.length(11);
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment