Skip to content

Commit

Permalink
added test cases for video element and it's poster attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ApoorvSaxena committed Oct 30, 2019
1 parent 0459e6d commit dc483f3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
6 changes: 3 additions & 3 deletions dist/lozad.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.lozad = factory());
}(this, function () { 'use strict';
(global.lozad = factory());
}(this, (function () { 'use strict';

/**
* Detect IE browser
Expand Down Expand Up @@ -174,4 +174,4 @@

return lozad;

}));
})));
2 changes: 1 addition & 1 deletion dist/lozad.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,32 @@ describe('lozad', () => {
})
})

describe('video', () => {
beforeEach(() => {
document.body.innerHTML = ''
const el = document.createElement('video')
el.dataset.toggleClass = 'test'
el.setAttribute('class', 'lozad')
el.setAttribute('data-poster', 'test')
document.body.appendChild(el)
window.HTMLMediaElement.prototype.load = () => { /* do nothing */ };
})

it('should not toggle till observe function is called', () => {
lozad()
const el = document.querySelectorAll('video')[0]
assert.strictEqual(false, el.classList.contains('test'))
})

it('should toggle class and poster value after observe function is called', () => {
const observer = lozad()
const el = document.querySelectorAll('video')[0]
observer.observe()
assert.strictEqual(true, el.classList.contains('test'))
assert.strictEqual('test', el.poster)
})
})

describe('exported IntersectionObserver', () => {
beforeEach(() => {
document.body.innerHTML = ''
Expand Down

0 comments on commit dc483f3

Please sign in to comment.