From ddf21caca60a94513f01ac8fba839cada466b6e9 Mon Sep 17 00:00:00 2001 From: Chris Sinchok Date: Thu, 30 Oct 2014 14:47:00 -0500 Subject: [PATCH] Updates for testing --- .travis.yml | 4 +++- karma.conf.js | 33 +++++++++++++++++++++++++++++++++ package.json | 7 +++++++ spec/VastPluginSpec.js | 28 ++++++++++++++-------------- videojs.vast.js | 2 +- 5 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 karma.conf.js diff --git a/.travis.yml b/.travis.yml index 8781733..d07eee6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,11 @@ language: node_js node_js: - '0.11' -- '0.10' before_install: - npm install -g grunt-cli +- bower install +script: +- karma start addons: sauce_connect: true env: diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..7a99292 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,33 @@ +module.exports = function(config) { + config.set({ + frameworks: ['jasmine'], + + autoWatch: true, + singleRun: false, + browsers: ['PhantomJS'], + + files: [ + 'bower_components/vast-client-js/vast-client.js', + 'bower_components/videojs/dist/video-js/video.js', + 'bower_components/videojs-contrib-ads/src/videojs.ads.js', + 'videojs.vast.js', + 'spec/VastPluginSpec.js' + ], + + preprocessors: { + 'videojs.vast.js': 'coverage' + }, + + reporters: ['progress', 'coverage'], + + coverageReporter: { + type: 'lcov', + dir: 'coverage/' + } + }); + + if (process.env.TRAVIS) { + config.singleRun = true; + config.autoWatch = false; + } +}; \ No newline at end of file diff --git a/package.json b/package.json index 35ee2c9..ebceba7 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,13 @@ "grunt-contrib-watch": "~0.5.3", "grunt-env": "~0.4.1", "grunt-simple-mocha": "~0.4.0", + + "karma": "^0.12.24", + "karma-coverage": "~0.2.5", + "karma-jasmine": "~0.2.0", + "karma-sauce-launcher": "~0.2.10", + "karma-phantomjs-launcher": "~0.1.4", + "lodash": "~2.4.1", "wd": "~0.2.12" }, diff --git a/spec/VastPluginSpec.js b/spec/VastPluginSpec.js index 22a4b4e..984de48 100644 --- a/spec/VastPluginSpec.js +++ b/spec/VastPluginSpec.js @@ -1,5 +1,6 @@ -(function(window, vjs, vast) { - "use strict"; +"use strict"; + +describe('videojs.vast plugin', function() { var player, isHtmlSupported, oldClearImmediate; @@ -11,7 +12,7 @@ video.src = "http://vjs.zencdn.net/v/oceans.mp4"; video.setAttribute = "controls"; document.body.appendChild(video); - isHtmlSupported = vjs.Html5.isSupported; + isHtmlSupported = videojs.Html5.isSupported; if (/phantomjs/gi.test(window.navigator.userAgent)) { // PhantomJS doesn't have a video element implementation // force support here so that the HTML5 tech is still used during @@ -32,7 +33,7 @@ oldClearImmediate = window.clearImmediate; } })(); - player = vjs(id); + player = videojs(id); player.ads(); player.vast({ url: "" @@ -42,7 +43,7 @@ afterEach(function() { player.dispose(); - vjs.Html5.isSupported = isHtmlSupported; + videojs.Html5.isSupported = isHtmlSupported; window.clearImmediate = oldClearImmediate; }); @@ -53,7 +54,7 @@ var video = document.createElement("video"); video.setAttribute = "controls"; document.body.appendChild(video); - this.p = vjs(video); + this.p = videojs(video); }); afterEach(function() { @@ -82,10 +83,10 @@ this.p.currentSrc = function() { return "video.mp4"; }; - spyOn(vast.client, "get"); + spyOn(DMVAST.client, "get"); this.p.ads(); this.p.vast({url:"i wanna go VAST!"}); - expect(vast.client.get).toHaveBeenCalledWith("i wanna go VAST!", jasmine.any(Function)); + expect(DMVAST.client.get).toHaveBeenCalledWith("i wanna go VAST!", jasmine.any(Function)); }); }); @@ -238,7 +239,7 @@ describe("getContent", function() { it("should bail out if there aren't playable media files", function() { - spyOn(vast.client, "get").and.callFake(function(url, callback){ + spyOn(DMVAST.client, "get").and.callFake(function(url, callback){ var fake_response = { ads: [{ creatives:[{ @@ -306,7 +307,7 @@ describe("non-linear ads", function() { beforeEach(function() { - spyOn(vast.client, "get") + spyOn(DMVAST.client, "get") .and.callFake(function(url, callback){ var fake_response = { ads: [{ @@ -321,10 +322,10 @@ }); }); it("should do nothing with non-linear ads, and report the error", function() { - spyOn(vast.util, "track"); + spyOn(DMVAST.util, "track"); spyOn(player, "trigger"); player.vast.getContent("some url"); - expect(vast.util.track).toHaveBeenCalledWith( + expect(DMVAST.util.track).toHaveBeenCalledWith( jasmine.any(String), jasmine.any(Object) ); expect(player.trigger).toHaveBeenCalledWith("adtimeout"); @@ -334,5 +335,4 @@ }); }); - -})(window, videojs, DMVAST); +}); \ No newline at end of file diff --git a/videojs.vast.js b/videojs.vast.js index 70762c7..17236ac 100644 --- a/videojs.vast.js +++ b/videojs.vast.js @@ -273,4 +273,4 @@ }; vjs.plugin('vast', vastPlugin); -}(window.videojs, window.DMVAST)); +}(videojs, DMVAST));