mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-09 03:46:16 -08:00
重写测试用例
This commit is contained in:
1 parent
50f51e413b
commit
cd89e8afd8
8 files changed
+9
-1477
No files matched your search
@@ -54,7 +54,7 @@ Specify the format for the `url`, use with `customType`
|
||||
```js
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: 'path/to/video.flv',
|
||||
url: '/assets/sample/video.flv',
|
||||
type: 'flv',
|
||||
});
|
||||
```
|
||||
@@ -71,7 +71,7 @@ Customize when loading third-party libraries
|
||||
```js
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: 'path/to/video.flv',
|
||||
url: '/assets/sample/video.flv',
|
||||
type: 'flv',
|
||||
customType: {
|
||||
flv: function (video, url, art) {
|
||||
@@ -815,12 +815,13 @@ Custom layer, The type of layer is an object or function
|
||||
[Run Code](/Configuration.layers)
|
||||
|
||||
```js
|
||||
var layer = '/assets/sample/layer.png';
|
||||
var art = new Artplayer({
|
||||
container: '.artplayer-app',
|
||||
url: '/assets/sample/video.mp4',
|
||||
layers: [
|
||||
{
|
||||
html: `<img style="width: 100px" src="/assets/sample/layer.png">`,
|
||||
html: `<img style="width: 100px" src="${layer}">`,
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '20px',
|
||||
|
||||
@@ -243,8 +243,9 @@ var art = new Artplayer({
|
||||
url: '/assets/sample/video.mp4',
|
||||
});
|
||||
|
||||
var layer = '/assets/sample/layer.png';
|
||||
art.layers.add({
|
||||
html: `<img style="width: 100px" src="/assets/sample/layer.png">`,
|
||||
html: `<img style="width: 100px" src="${layer}">`,
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: '20px',
|
||||
|
||||
+1
-2
@@ -10,9 +10,8 @@
|
||||
"dev": "npx cross-env NODE_ENV=development node ./scripts/dev.js",
|
||||
"start": "npx cross-env NODE_ENV=development npx servor docs index.html 8081 5000",
|
||||
"build": "npx cross-env NODE_ENV=production node ./scripts/build.js",
|
||||
"build:all": "npm run build all && npm run test:doc && git add . && git commit -m \"build all packages\" -n ",
|
||||
"build:all": "npm run build all && git add . && git commit -m \"build all packages\" -n ",
|
||||
"test": "npx cross-env NODE_ENV=test mocha-chrome ./test/index.html --mocha '{\"ui\":\"bdd\"}'",
|
||||
"test:doc": "node ./scripts/creatTestFromDoc.js",
|
||||
"lint": "npx eslint packages/*/src",
|
||||
"sizereport": "npx sizereport --config"
|
||||
},
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const logger = require('./logger');
|
||||
|
||||
try {
|
||||
const documentText = [
|
||||
'README.md',
|
||||
'class.md',
|
||||
'events.md',
|
||||
'libraries.md',
|
||||
'options.md',
|
||||
'properties.md',
|
||||
'properties.md',
|
||||
]
|
||||
.map((name) => {
|
||||
return fs.readFileSync(path.resolve(__dirname, '../docs/document/' + name), 'utf-8');
|
||||
})
|
||||
.join('');
|
||||
const jsTests = documentText.match(/\[Run Code\]\(\/([\s\S]*?)\)\n\n\`{3}js([\s\S]*?)\`{3}/g);
|
||||
const jsBlocks = jsTests.map((item) => {
|
||||
const result = item.match(/\[Run Code\]\(\/([\s\S]*)\)\n\n\`{3}js([\s\S]*?)\`{3}/);
|
||||
return {
|
||||
name: result[1],
|
||||
code: result[2],
|
||||
};
|
||||
});
|
||||
|
||||
fs.writeFileSync(
|
||||
path.resolve(__dirname, '../test/document.test.js'),
|
||||
`
|
||||
describe('Document', function() {
|
||||
afterEach(function() {
|
||||
[...Artplayer.instances].forEach(art => {
|
||||
art.destroy(true);
|
||||
});
|
||||
});
|
||||
|
||||
${jsBlocks
|
||||
.map((item) => {
|
||||
return `
|
||||
it(\`${item.name}\`, function() {
|
||||
${item.code}
|
||||
});
|
||||
`;
|
||||
})
|
||||
.join('\n')};
|
||||
});
|
||||
`,
|
||||
);
|
||||
|
||||
logger.success('Create a test case from the document successfully');
|
||||
} catch (error) {
|
||||
logger.fatal(error);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
describe('Constructor', function() {
|
||||
var url = 'https://zhw2590582.github.io/assets-cdn/video/one-more-time-one-more-chance-480p.mp4';
|
||||
var url = 'https://artplayer.org/assets/sample/video.mp4';
|
||||
|
||||
afterEach(function() {
|
||||
[...Artplayer.instances].forEach(art => {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -40,11 +40,9 @@
|
||||
<script src="https://cdn.bootcss.com/dashjs/2.9.2/dash.all.min.js"></script>
|
||||
<script src="https://cdn.bootcss.com/shaka-player/2.5.0-beta/shaka-player.compiled.js"></script>
|
||||
<script src="https://cdn.bootcss.com/webtorrent/0.102.4/webtorrent.min.js"></script>
|
||||
<!-- <script src="../docs/uncompiled/artplayer.js"></script> -->
|
||||
<script src="../dist/artplayer.js"></script>
|
||||
<script src="./constructor.test.js"></script>
|
||||
<script src="./option.test.js"></script>
|
||||
<script src="./document.test.js"></script>
|
||||
<script>
|
||||
mocha.checkLeaks();
|
||||
mocha.run();
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
describe('Option', function() {
|
||||
var url = 'https://zhw2590582.github.io/assets-cdn/video/one-more-time-one-more-chance-480p.mp4';
|
||||
var url = 'https://artplayer.org/assets/sample/video.mp4';
|
||||
|
||||
afterEach(function() {
|
||||
[...Artplayer.instances].forEach(art => {
|
||||
|
||||
Reference in new issue
Block a user