修改多实例时的图标bug

This commit is contained in:
Harvey Zack committed 2019-04-16 14:26:16 +08:00
1 parent 1573364202
commit 381a7e657e
7 files changed
+170 -138

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
describe('Constructor', function() {
it('Constructor is a global variable', function() {
expect(Artplayer).to.be.an('function');
expect(Artplayer.instances).to.be.an('array');
expect(Artplayer.instances.length).to.be.equal(0);
});
it('Instance state', function() {
var sample1 = new Artplayer({ ...artBaseOption, container: '.sample1' });
expect(sample1.id).to.equal(1);
var sample2 = new Artplayer({ ...artBaseOption, container: '.sample2' });
expect(sample2.id).to.equal(2);
var sample3 = new Artplayer({ ...artBaseOption, container: '.sample3' });
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, but got \'null\'/);
});
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);
});
});
+22 -7
View File
@@ -6,25 +6,40 @@
<link href="../dist/artplayer.css" rel="stylesheet" />
<style>
.artplayer-app {
width: 400px;
display: flex;
height: 300px;
margin: 20px auto;
opacity: 0.1;
background: #000;
border-bottom: 1px solid #999;
}
.artplayer-app > div {
display: flex;
justify-content: center;
align-items: center;
flex: 1;
padding: 10px;
border-right: 1px solid #999;
}
</style>
</head>
<body>
<div class="artplayer-app"></div>
<div class="artplayer-app">
<div class="sample1">sample1</div>
<div class="sample2">sample2</div>
<div class="sample3">sample3</div>
</div>
<div id="mocha"></div>
<script src="https://unpkg.com/chai/chai.js"></script>
<script src="https://unpkg.com/mocha@5.2.0/mocha.js"></script>
<script>
window.mocha.setup('bdd');
window.expect = window.chai.expect;
window.artBaseOption = {
url: 'https://blog.zhw-island.com/assets-cdn/video/one-more-time-one-more-chance-480p.mp4',
autoSize: true,
};
</script>
<script src="../dist/artplayer.js"></script>
<script src="./index.test.js"></script>
<script src="../docs/uncompiled/artplayer.js"></script>
<script src="./constructor.test.js"></script>
<script>
mocha.checkLeaks();
mocha.run();
-31
View File
@@ -1,31 +0,0 @@
var artBaseOption = {
container: document.querySelector('.artplayer-app'),
url: 'https://blog.zhw-island.com/assets-cdn/video/one-more-time-one-more-chance-480p.mp4',
};
describe('Detect registration status', function() {
it('Constructor is a global variable', function() {
expect(Artplayer).to.be.an('function');
expect(Artplayer.instances).to.be.an('array');
});
it('Instance state', function() {
var art = new Artplayer(artBaseOption);
expect(art).to.be.an('object');
expect(art.id).to.equal(1);
});
it('Throw error when multiple instances on the same dom element', function() {
expect(function() {
new Artplayer(artBaseOption);
}).to.throw(/Cannot mount multiple instances on the same dom element/);
});
it('Destroy all instances', function() {
expect(Artplayer.instances.length).to.equal(1);
Artplayer.instances.forEach(art => {
art.destroy(true);
});
expect(Artplayer.instances.length).to.equal(0);
});
});