添加测试用例

This commit is contained in:
Harvey Zack committed 2018-11-29 16:38:59 +08:00
1 parent 02009e854d
commit dc8405403c
3 files changed
+18 -13

No files matched your search

+2 -1
View File
@@ -9,7 +9,8 @@
width: 400px;
height: 300px;
margin: 20px auto;
opacity: 0.2;
opacity: 0.1;
background: #000;
}
</style>
</head>
+12 -8
View File
@@ -5,18 +5,14 @@ var artBaseOption = {
describe('Detect registration status', function() {
it('Constructor is a global variable', function() {
expect(window.Artplayer).to.be.an('function');
expect(window.Artplayer.version).to.be.an('string');
expect(window.Artplayer.env).to.be.an('string');
expect(window.Artplayer.config).to.be.an('object');
expect(window.Artplayer.utils).to.be.an('object');
expect(window.Artplayer.DEFAULTS).to.be.an('object');
expect(window.Artplayer.instances).to.be.an('array');
expect(Artplayer).to.be.an('function');
expect(Artplayer.instances).to.be.an('array');
});
it('Instantiation state', function() {
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() {
@@ -24,4 +20,12 @@ describe('Detect registration status', 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);
});
});