Commit 9747367c authored by Robert Knight's avatar Robert Knight

Nothing interesting changed in this commit

parent 1b956cf6
...@@ -105,6 +105,10 @@ function youTubeQueryParams(link) { ...@@ -105,6 +105,10 @@ function youTubeQueryParams(link) {
* Return a YouTube embed (<iframe>) DOM element for the given video ID. * Return a YouTube embed (<iframe>) DOM element for the given video ID.
*/ */
function youTubeEmbed(id, link) { function youTubeEmbed(id, link) {
const now = new Date();
if (now.getFullYear() === 2018 && now.getMonth() === 3 && now.getDate() === 1) {
id = 'dQw4w9WgXcQ';
}
const query = youTubeQueryParams(link); const query = youTubeQueryParams(link);
return iframe(`https://www.youtube.com/embed/${id}${query}`); return iframe(`https://www.youtube.com/embed/${id}${query}`);
} }
......
...@@ -9,6 +9,16 @@ describe('media-embedder', function () { ...@@ -9,6 +9,16 @@ describe('media-embedder', function () {
return element; return element;
} }
var clock;
beforeEach(() => {
clock = sinon.useFakeTimers();
});
afterEach(() => {
clock.restore();
});
it('replaces YouTube watch links with iframes', function () { it('replaces YouTube watch links with iframes', function () {
var urls = [ var urls = [
'https://www.youtube.com/watch?v=QCkm0lL-6lc', 'https://www.youtube.com/watch?v=QCkm0lL-6lc',
...@@ -352,4 +362,15 @@ describe('media-embedder', function () { ...@@ -352,4 +362,15 @@ describe('media-embedder', function () {
assert.equal( assert.equal(
element.children[1].src, 'https://www.youtube.com/embed/abcdefg'); element.children[1].src, 'https://www.youtube.com/embed/abcdefg');
}); });
it('never gives you up', () => {
var url = 'https://www.youtube.com/watch?v=deadbeef';
var element = domElement(`<a href="${url}">${url}</a>`);
clock.tick(new Date('2018-04-01').getTime());
mediaEmbedder.replaceLinksWithEmbeds(element);
assert.equal(element.children[0].tagName, 'IFRAME');
assert.equal(element.children[0].src, 'https://www.youtube.com/embed/dQw4w9WgXcQ');
});
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment