@mailonline/video-ad-sdk
Advanced tools
Comparing version 1.3.3 to 1.3.4
{ | ||
"name": "@mailonline/video-ad-sdk", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Video ad SDK to load and play video ads", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -21,2 +21,10 @@ import { | ||
import startVideoAd from '../startVideoAd'; | ||
import { | ||
start, | ||
closeLinear | ||
} from '../../../tracker/linearEvents'; | ||
import { | ||
adStopped, | ||
adUserClose | ||
} from '../../../adUnit/helpers/vpaid/api'; | ||
@@ -174,3 +182,28 @@ jest.mock('../../../adUnit/createVideoAdUnit'); | ||
test('must cancel the ad unit if there is an error starting the VPAID ad unit', async () => { | ||
[ | ||
adUserClose, | ||
adStopped, | ||
closeLinear | ||
].forEach((event) => { | ||
test(`must cancel the ad unit start on '${event}' event`, async () => { | ||
expect.assertions(1); | ||
const adUnit = createAdUnitMock(vastAdChain, videoAdContainer, options); | ||
createVideoAdUnit.mockImplementation(() => { | ||
adUnit.start = () => { | ||
adUnit.emit(event); | ||
}; | ||
return adUnit; | ||
}); | ||
try { | ||
await startVideoAd(vpaidAdChain, videoAdContainer, options); | ||
} catch (error) { | ||
expect(error.message).toBe(`Ad unit start rejected due to event '${event}'`); | ||
} | ||
}); | ||
}); | ||
test('must onAdReady event if the ad unit gets canceled', async () => { | ||
expect.assertions(5); | ||
@@ -182,3 +215,2 @@ canPlay.mockReturnValue(false); | ||
createVideoAdUnit.mockImplementation(() => { | ||
// eslint-disable-next-line promise/always-return, promise/always-return, promise/catch-or-return, promise/prefer-await-to-then | ||
adUnit.start = () => { | ||
@@ -212,3 +244,3 @@ adUnit.__simulateError(adUnitError); | ||
adUnit.start = () => { | ||
adUnit.emit('start'); | ||
adUnit.emit(start); | ||
}; | ||
@@ -263,3 +295,3 @@ | ||
adUnit.start = () => { | ||
adUnit.emit('start'); | ||
adUnit.emit(start); | ||
}; | ||
@@ -266,0 +298,0 @@ |
@@ -5,2 +5,10 @@ import createVideoAdUnit from '../../adUnit/createVideoAdUnit'; | ||
import canPlay from '../../adUnit/helpers/media/canPlay'; | ||
import { | ||
start, | ||
closeLinear | ||
} from '../../tracker/linearEvents'; | ||
import { | ||
adStopped, | ||
adUserClose | ||
} from '../../adUnit/helpers/vpaid/api'; | ||
@@ -30,4 +38,10 @@ const validate = (vastChain, videoAdContainer) => { | ||
const startAdUnit = (adUnit, {onAdReady}) => new Promise((resolve, reject) => { | ||
const createRejectHandler = (event) => () => | ||
reject(new Error(`Ad unit start rejected due to event '${event}'`)); | ||
adUnit.onError(reject); | ||
adUnit.on('start', () => resolve(adUnit)); | ||
adUnit.on(start, () => resolve(adUnit)); | ||
adUnit.on(adUserClose, createRejectHandler(adUserClose)); | ||
adUnit.on(closeLinear, createRejectHandler(closeLinear)); | ||
adUnit.on(adStopped, createRejectHandler(adStopped)); | ||
@@ -34,0 +48,0 @@ onAdReady(adUnit); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2107900
28071