Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Updates for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Sinchok committed Oct 30, 2014
1 parent 3ad79aa commit ddf21ca
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
33 changes: 33 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -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;
}
};
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
28 changes: 14 additions & 14 deletions spec/VastPluginSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(function(window, vjs, vast) {
"use strict";
"use strict";

describe('videojs.vast plugin', function() {

var player, isHtmlSupported, oldClearImmediate;

Expand All @@ -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
Expand All @@ -32,7 +33,7 @@
oldClearImmediate = window.clearImmediate;
}
})();
player = vjs(id);
player = videojs(id);
player.ads();
player.vast({
url: ""
Expand All @@ -42,7 +43,7 @@

afterEach(function() {
player.dispose();
vjs.Html5.isSupported = isHtmlSupported;
videojs.Html5.isSupported = isHtmlSupported;
window.clearImmediate = oldClearImmediate;
});

Expand All @@ -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() {
Expand Down Expand Up @@ -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));
});
});

Expand Down Expand Up @@ -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:[{
Expand Down Expand Up @@ -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: [{
Expand All @@ -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");
Expand All @@ -334,5 +335,4 @@
});

});

})(window, videojs, DMVAST);
});
2 changes: 1 addition & 1 deletion videojs.vast.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,4 @@
};

vjs.plugin('vast', vastPlugin);
}(window.videojs, window.DMVAST));
}(videojs, DMVAST));

0 comments on commit ddf21ca

Please sign in to comment.