Skip to content

Commit 0559611

Browse files
committed
added test
1 parent d4d4435 commit 0559611

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

test/browser.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ test.beforeEach(t => {
2525
global.window = dom.window;
2626
})
2727

28-
const createDomNode = (vendor, src) => {
28+
const createDomNode = (vendor, src, title, thumbnail) => {
2929
const node = document.createElement('div');
3030
node.classList.add('lazyframe');
3131
node.setAttribute('data-src', src)
3232
if (vendor) {
3333
node.setAttribute('data-vendor', vendor)
3434
}
35+
if (title) {
36+
node.setAttribute('data-title', title);
37+
}
38+
if (thumbnail) {
39+
node.setAttribute('data-thumbnail', thumbnail);
40+
}
3541
document.body.appendChild(node);
3642
return node;
3743
}
@@ -88,4 +94,14 @@ test('should call onAppend callback function', (t) => {
8894
node2.click();
8995

9096
t.is(i, 2)
97+
})
98+
99+
test('should use data-title', (t) => {
100+
const title = 'custom title'
101+
const node = createDomNode('youtube', 'http://www.youtube.com/embed/iwGFalTRHDB/?rel=0', title)
102+
103+
window.lazyframe('.lazyframe');
104+
105+
node.click()
106+
t.is(document.querySelector('.lazyframe__title').textContent, title)
91107
})

0 commit comments

Comments
 (0)