skillbox/client/tests/unit/srf.spec.ts

25 lines
1.0 KiB
TypeScript

import { getVideoId } from '../../src/helpers/video';
import { mount } from '@vue/test-utils';
import SrfEmbed from '@/components/videos/SrfEmbed.vue';
const url = 'https://www.srf.ch/play/tv/popupvideoplayer?id=6db02b8b-975c-4e3e-8260-f1e6eca1d8ed';
const embedUrl =
'https://www.srf.ch/play/embed?urn=urn:srf:video:6db02b8b-975c-4e3e-8260-f1e6eca1d8ed&subdivisions=false';
describe('SRF Video Embed', () => {
it('should return the correct embed url', () => {
const videoId = getVideoId(url);
const embedId = '6db02b8b-975c-4e3e-8260-f1e6eca1d8ed';
expect(videoId).toBe(embedId);
});
it('should construct the correct iframe', () => {
const props = {
url,
};
const wrapper = mount(SrfEmbed, {
props,
});
expect(wrapper.attributes('src')).toBe(embedUrl);
});
});
// <iframe width="560" height="315" src="https://www.srf.ch/play/embed?urn=urn:srf:video:6db02b8b-975c-4e3e-8260-f1e6eca1d8ed&subdivisions=false" allowfullscreen allow="geolocation *; autoplay; encrypted-media"></iframe>