Skip to content

Commit

Permalink
✅ [amp-redbull-player] Add unit tests to increase coverage. (#32904)
Browse files Browse the repository at this point in the history
Fixes #32902 

This change increases code coverage in `amp-redbull-player` from 41.67% to 63.33%. 
(Measured using the `--coverage` flag with `gulp unit`)
  • Loading branch information
rbeckthomas committed Feb 25, 2021
1 parent 2ef25d7 commit c88fbbb
Showing 1 changed file with 61 additions and 17 deletions.
78 changes: 61 additions & 17 deletions extensions/amp-redbull-player/0.1/test/test-amp-redbull.js
Expand Up @@ -48,25 +48,69 @@ describes.realWin(
});
}

it('renders the Red Bull player', async () => {
const player = await getRedBullElement(
'rrn:content:videos:3965a26c-052e-575f-a28b-ded6bee23ee1:en-INT'
);
const playerIframe = player.querySelector('iframe');
expect(playerIframe).to.not.be.null;
expect(playerIframe.src).to.equal(
'https://player.redbull.com/amp/amp-iframe.html?videoId=' +
encodeURIComponent(
'rrn:content:videos:3965a26c-052e-575f-a28b-ded6bee23ee1:en-INT'
) +
'&skinId=com&ampTagId=rbvideo&locale=global'
);
describe('rendering', async () => {
it('renders the Red Bull player', async () => {
const player = await getRedBullElement(
'rrn:content:videos:3965a26c-052e-575f-a28b-ded6bee23ee1:en-INT'
);
const playerIframe = player.querySelector('iframe');
expect(playerIframe).to.not.be.null;
expect(playerIframe.src).to.equal(
'https://player.redbull.com/amp/amp-iframe.html?videoId=' +
encodeURIComponent(
'rrn:content:videos:3965a26c-052e-575f-a28b-ded6bee23ee1:en-INT'
) +
'&skinId=com&ampTagId=rbvideo&locale=global'
);
});

it('fails without videoId', () => {
return getRedBullElement(null).should.eventually.be.rejectedWith(
/The data-param-videoid attribute is required/
);
});

it('removes iframe after unlayoutCallback', async () => {
const player = await getRedBullElement(
'rrn:content:videos:3965a26c-052e-575f-a28b-ded6bee23ee1:en-INT'
);
const playerIframe = player.querySelector('iframe');
expect(playerIframe).to.not.be.null;

const impl = await player.getImpl(false);
impl.unlayoutCallback();
expect(player.querySelector('iframe')).to.be.null;
expect(impl.iframe_).to.be.null;
});
});
describe('methods', async () => {
let impl;
beforeEach(async () => {
const player = await getRedBullElement(
'rrn:content:videos:3965a26c-052e-575f-a28b-ded6bee23ee1:en-INT'
);
impl = await player.getImpl(false);
});

it('is interactive', () => {
expect(impl.isInteractive()).to.be.true;
});

it('supports platform', () => {
expect(impl.supportsPlatform()).to.be.true;
});

it('does not pre-implement MediaSession API', () => {
expect(impl.preimplementsMediaSessionAPI()).to.be.false;
});

it('does not pre-implement auto-fullscreen', () => {
expect(impl.preimplementsAutoFullscreen()).to.be.false;
});

it('fails without videoId', () => {
return getRedBullElement(null).should.eventually.be.rejectedWith(
/The data-param-videoid attribute is required/
);
it('is not fullscreen', () => {
expect(impl.isFullscreen()).to.be.false;
});
});
}
);

0 comments on commit c88fbbb

Please sign in to comment.