hexo-tag-youtube-responsive
Version:
Hexo tag plugin to embed a Youtube player that auto resizes with your responsive layout
44 lines (34 loc) • 1.65 kB
JavaScript
const rewire = require('rewire');
const should = require('should');
const tag = rewire('../index');
const getUrl = tag.__get__('getUrl');
describe('getUrl', () => {
it('should embed a video', () => {
const url = getUrl({ type: 'video', id: 12345 });
url.toString().should.be.equal('https://www.youtube.com/embed/12345');
});
it('should embed a video with privacy mode', () => {
const url = getUrl({ type: 'video', id: 12345, privacy_mode: 'yes' });
url.toString().should.be.equal('https://www.youtube-nocookie.com/embed/12345');
});
it('should embed a playlist', () => {
const url = getUrl({ type: 'playlist', id: 12345 });
url.toString().should.be.equal('https://www.youtube.com/embed?listType=playlist&list=12345');
});
it('should embed a user playlist', () => {
const url = getUrl({ type: 'user', id: 12345 });
url.toString().should.be.equal('https://www.youtube.com/embed?listType=user_uploads&list=12345');
});
it('should embed search result', () => {
const url = getUrl({ type: 'search', id: 12345 });
url.toString().should.be.equal('https://www.youtube.com/embed?listType=search&list=12345');
});
it('should autoplay the video', () => {
const url = getUrl({ type: 'search', id: 12345, autoplay: 1 });
url.toString().should.be.equal('https://www.youtube.com/embed?listType=search&list=12345&autoplay=1');
});
it('should use lang preference for close caption', () => {
const url = getUrl({ type: 'search', id: 12345, cc_lang_pref: 'fr' });
url.toString().should.be.equal('https://www.youtube.com/embed?listType=search&list=12345&cc_lang_pref=fr');
});
});