Add unit test setup files and sample plugin unit test
This commit is contained in:
parent
583f5b0abe
commit
341fa9f616
2 changed files with 63 additions and 0 deletions
34
test/karma.conf.js
Normal file
34
test/karma.conf.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
module.exports = function(config){
|
||||
config.set({
|
||||
|
||||
basePath : '../',
|
||||
|
||||
files : [
|
||||
'bower_components/angular/angular.js',
|
||||
'bower_components/angular-route/angular-route.js',
|
||||
'bower_components/angular-mocks/angular-mocks.js',
|
||||
'js/**/*.js',
|
||||
'test/unit/**/*.js'
|
||||
],
|
||||
|
||||
autoWatch : true,
|
||||
|
||||
frameworks: ['jasmine'],
|
||||
|
||||
browsers : ['PhantomJS'],
|
||||
|
||||
singleRun: true,
|
||||
|
||||
plugins : [
|
||||
'karma-phantomjs-launcher',
|
||||
'karma-jasmine',
|
||||
'karma-junit-reporter'
|
||||
],
|
||||
|
||||
junitReporter : {
|
||||
outputFile: 'test_out/unit.xml',
|
||||
suite: 'unit'
|
||||
}
|
||||
|
||||
});
|
||||
};
|
29
test/unit/plugins.js
Normal file
29
test/unit/plugins.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* plugins go here */
|
||||
|
||||
var msg = function(msg) {
|
||||
return {'text': msg }
|
||||
}
|
||||
|
||||
var metadata_name = function(message) {
|
||||
return message['metadata'][0]['name']
|
||||
}
|
||||
|
||||
describe('filter', function() {
|
||||
beforeEach(module('plugins'));
|
||||
|
||||
|
||||
describe('Plugins', function() {
|
||||
beforeEach(module(function($provide) {
|
||||
$provide.value('version', 'TEST_VER');
|
||||
}));
|
||||
|
||||
|
||||
it('should recognize youtube videos', inject(function(plugins) {
|
||||
expect(
|
||||
metadata_name(
|
||||
plugins.PluginManager.contentForMessage(msg('https://www.youtube.com/watch?v=dQw4w9WgXcQ'))
|
||||
)
|
||||
).toEqual('YouTube video');
|
||||
}));
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue