Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ [amp-redbull-player] Add unit tests to increase coverage. #32904

Merged
merged 2 commits into from
Feb 25, 2021
Merged
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
78 changes: 61 additions & 17 deletions extensions/amp-redbull-player/0.1/test/test-amp-redbull.js
Original file line number Diff line number Diff line change
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;
});
});
}
);