mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-12 23:36:15 -08:00
分离工具函数
This commit is contained in:
1 parent
7a84c262da
commit
8ef582f714
22 files changed
+724
-687
No files matched your search
+11
-27
@@ -1,4 +1,12 @@
|
||||
var url = 'https://zhw2590582.github.io/assets-cdn/video/one-more-time-one-more-chance-480p.mp4';
|
||||
|
||||
describe('Constructor', function() {
|
||||
afterEach(function() {
|
||||
[...Artplayer.instances].forEach(art => {
|
||||
art.destroy(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('Constructor is a global variable', function() {
|
||||
expect(Artplayer).to.be.an('function');
|
||||
expect(Artplayer.instances).to.be.an('array');
|
||||
@@ -6,35 +14,11 @@ describe('Constructor', function() {
|
||||
});
|
||||
|
||||
it('Instance state', function() {
|
||||
var sample1 = new Artplayer({ ...artBaseOption, container: '.sample1' });
|
||||
var sample1 = new Artplayer({ container: '.sample1', url: url });
|
||||
expect(sample1.id).to.equal(1);
|
||||
var sample2 = new Artplayer({ ...artBaseOption, container: '.sample2' });
|
||||
var sample2 = new Artplayer({ container: '.sample2', url: url });
|
||||
expect(sample2.id).to.equal(2);
|
||||
var sample3 = new Artplayer({ ...artBaseOption, container: '.sample3' });
|
||||
var sample3 = new Artplayer({ container: '.sample3', url: url });
|
||||
expect(sample3.id).to.equal(3);
|
||||
});
|
||||
|
||||
it('Throw error when multiple instances on the same dom element', function() {
|
||||
expect(function() {
|
||||
new Artplayer({ ...artBaseOption, container: '.sample1' });
|
||||
}).to.throw(/Cannot mount multiple instances on the same dom element/);
|
||||
});
|
||||
|
||||
it('Throw error when container is not a dom element or selector', function() {
|
||||
expect(function() {
|
||||
new Artplayer(
|
||||
Object.assign({}, artBaseOption, {
|
||||
container: null,
|
||||
}),
|
||||
);
|
||||
}).to.throw(/option.container require \'string\' or \'Element\' type/);
|
||||
});
|
||||
|
||||
it('Destroy all instances', function() {
|
||||
expect(Artplayer.instances.length).to.equal(3);
|
||||
[...Artplayer.instances].forEach(art => {
|
||||
art.destroy(true);
|
||||
});
|
||||
expect(Artplayer.instances.length).to.equal(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user