Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var xml = function(options) {
icon.element(r.type, r.uri, (r.creativeType) ? { creativeType : r.creativeType } : {});
});
});
creativeType.element('Duration', c.Duration);
if (c.Duration) creativeType.element('Duration', c.Duration);
var trackingEvents = creativeType.element('TrackingEvents');
c.trackingEvents.forEach(function(trackingEvent){
if (track) {
Expand All @@ -72,10 +72,12 @@ var xml = function(options) {
c.videoClicks.forEach(function(videoClick){
videoClicks.element(videoClick.type, videoClick.url, { id : videoClick.id });
});
var mediaFiles = creativeType.element('MediaFiles');
c.mediaFiles.forEach(function(mediaFile) {
mediaFiles.element('MediaFile', mediaFile.attributes).cdata(mediaFile.url);
});
if (c.mediaFiles && c.mediaFiles.length > 0) {
var mediaFiles = creativeType.element('MediaFiles');
c.mediaFiles.forEach(function(mediaFile) {
mediaFiles.element('MediaFile', mediaFile.attributes).cdata(mediaFile.url);
});
}
});

nonLinearCreatives.forEach(function(c){
Expand Down
2 changes: 1 addition & 1 deletion lib/creative.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Creative(type, settings) {

if (settings.Duration) {
this.Duration = settings.Duration;
} else if (type === 'Linear') {
} else if (type === 'Linear' && !settings.Wrapper) {
throw new Error('A Duration is required for all creatives. Consider defaulting to "00:00:00"');
}
this.attributes = {};
Expand Down
8 changes: 6 additions & 2 deletions test/wrapper.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var test = require('tap').test
, VAST = require('../index.js')
, vast = new VAST();
, vast = new VAST()
, ad
, creative;

test('Validate ad settings', function(t){
t.throws(function(){
Expand All @@ -21,12 +23,14 @@ test('Validate ad settings', function(t){
t.end();
});

vast.attachAd({
ad = vast.attachAd({
structure : 'wrapper'
, AdSystem : 'Common name of the ad'
, sequence : 23
, Error: 'http://error.err'
, VASTAdTagURI : 'http://example.com'
}).attachImpression({ id: Date.now(), url : 'http://impression.com' });

creative = ad.attachCreative('Linear', { Wrapper : true } )

module.exports = vast;