-
Notifications
You must be signed in to change notification settings - Fork 8
/
test.js
31 lines (25 loc) · 892 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var test = require('tape')
var window = require('global/window')
var YoutubeComponent = require('./')
function makeID () {
return 'testid-' + Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1)
}
function createTestElement () {
var testRoot = document.createElement('div')
testRoot.id = makeID()
document.body.appendChild(testRoot)
return testRoot
}
function renderAndMount (testEl, video) {
var el = video.render('https://www.youtube.com/watch?v=HEXWRTEbj1I')
testEl.appendChild(el)
}
test('render a video', function (t) {
var testRoot = createTestElement()
var video = new YoutubeComponent()
t.doesNotThrow(renderAndMount.bind(null, testRoot, video), 'Able to render a video')
window.setTimeout(function () {
t.true(video.element.children[0].src.includes('youtube.com/embed/HEXWRTEbj1I'), 'A video iframe is added')
t.end()
}, 1000)
})