From 341fa9f616a9e05cb64c09d9407b691d2610da47 Mon Sep 17 00:00:00 2001 From: David Cormier Date: Sat, 2 Aug 2014 11:46:19 -0400 Subject: [PATCH] Add unit test setup files and sample plugin unit test --- test/karma.conf.js | 34 ++++++++++++++++++++++++++++++++++ test/unit/plugins.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/karma.conf.js create mode 100644 test/unit/plugins.js diff --git a/test/karma.conf.js b/test/karma.conf.js new file mode 100644 index 0000000..379b976 --- /dev/null +++ b/test/karma.conf.js @@ -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' + } + + }); +}; diff --git a/test/unit/plugins.js b/test/unit/plugins.js new file mode 100644 index 0000000..3f35d69 --- /dev/null +++ b/test/unit/plugins.js @@ -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'); + })); + }); +});