Skip to content

Commit

Permalink
add karma test
Browse files Browse the repository at this point in the history
  • Loading branch information
outsideris committed Jan 15, 2014
1 parent adc7b1d commit 9471b4e
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 6 deletions.
9 changes: 7 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ module.exports = function(grunt) {
}
}
},
watch: {}
watch: {},
karma: {
'summernote': {
configFile: './test/karma.conf.js'
}
}
});

// These plugins provide necessary tasks.
Expand All @@ -31,6 +36,6 @@ module.exports = function(grunt) {

// Default task.
grunt.registerTask('default', []);
grunt.registerTask('test', []);
grunt.registerTask('test', ['karma:summernote']);
grunt.registerTask('lint', ['jshint']);
};
5 changes: 4 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"summernote": "~0.5.0",
"angular": "~1.2.8"
},
"devDependencies": {}
"devDependencies": {
"chai": "~1.8.1",
"angular-mocks": "~1.2.8"
}
}
68 changes: 68 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Karma configuration
// Generated on Wed Jan 15 2014 20:50:47 GMT+0900 (KST)

module.exports = function(config) {
config.set({

// base path, that will be used to resolve files and exclude
basePath: '',


// frameworks to use
frameworks: ['mocha'],


// list of files / patterns to load in the browser
files: [
'"test/**/*.test.js"'
],


// list of files to exclude
exclude: [

],


// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
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_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['Chrome'],


// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.7.2",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-watch": "~0.5.3"
"grunt-contrib-watch": "~0.5.3",
"mocha": "~1.17.0",
"karma-script-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3",
"karma-html2js-preprocessor": "~0.1.0",
"requirejs": "~2.1.10",
"karma-requirejs": "~0.2.1",
"karma-coffee-preprocessor": "~0.1.2",
"karma-phantomjs-launcher": "~0.1.1",
"karma": "~0.10.9",
"karma-mocha": "~0.1.1",
"grunt-karma": "~0.6.2"
},
"dependencies": {
}
"dependencies": {}
}
42 changes: 42 additions & 0 deletions test/angular-summernote.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright (c) 2013 JeongHoon Byun aka "Outsider", <http://blog.outsider.ne.kr/>
* Licensed under the MIT license.
* <http://outsider.mit-license.org/>
*/
describe('Summernote directive', function() {
'use strict';

var $rootScope, $compile, element;

beforeEach(module('summernote'));
beforeEach(inject(function(_$compile_, _$rootScope_) {
$compile = _$compile_;
$rootScope = _$rootScope_;
}));

describe('initialization', function() {

it('has "summernote" class', function () {
element = $compile('<summernote></summernote>')($rootScope);
$rootScope.$digest();

expect($(element.get(0)).hasClass('summernote')).to.be.true;
});

it('works with "summernote" element', function () {
element = $compile('<summernote></summernote>')($rootScope);
$rootScope.$digest();

expect(element.next().hasClass('note-editor')).to.be.true;
});

it('works with "summernote" attribute', function () {
element = $compile('<div summernote></div>')($rootScope);
$rootScope.$digest();

expect(element.next().hasClass('note-editor')).to.be.true;
});

});

});
6 changes: 6 additions & 0 deletions test/chai.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Copyright (c) 2013 JeongHoon Byun aka "Outsider", <http://blog.outsider.ne.kr/>
* Licensed under the MIT license.
* <http://outsider.mit-license.org/>
*/
var expect = chai.expect;
86 changes: 86 additions & 0 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Karma configuration
// Generated on Sat Jan 04 2014 16:46:43 GMT+0900 (KST)

module.exports = function(config) {
'use strict';

config.set({

// base path, that will be used to resolve files and exclude
basePath: '',


// frameworks to use
frameworks: ['mocha'],


// list of files / patterns to load in the browser
files: [
// dependencies
'../examples/components/jquery/jquery.js',
'../examples/components/angular/angular.js',
'../examples/components/bootstrap/dist/js/bootstrap.min.js',
'../examples/components/summernote/dist/summernote.min.js',

// application code
'../src/**/*.js',

// test dependencies
'../examples/components/angular-mocks/angular-mocks.js',
'../examples/components/chai/chai.js',
'mocha.conf.js',
'chai.conf.js',

// test code
'*.test.js'
],


// list of files to exclude
exclude: [

],


// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
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_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,


// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['Chrome'],


// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
};
3 changes: 3 additions & 0 deletions test/mocha.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
window.mocha.setup({
timeout: 5000
});

0 comments on commit 9471b4e

Please sign in to comment.