Adopt lerna and typescript
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"rules": {
|
||||
"no-undef": 0,
|
||||
"camelcase": 0
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
const TIMEOUT = 60000;
|
||||
const IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
||||
const OPTIONS = {
|
||||
corePath: IS_BROWSER ? 'http://localhost:3000/node_modules/@ffmpeg/core/dist/ffmpeg-core.js' : '@ffmpeg/core',
|
||||
};
|
||||
const FLAME_MP4_LENGTH = 100374;
|
||||
const META_FLAME_MP4_LENGTH = 100408;
|
||||
const META_FLAME_MP4_LENGTH_NO_SPACE = 100404;
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = {
|
||||
TIMEOUT,
|
||||
IS_BROWSER,
|
||||
OPTIONS,
|
||||
FLAME_MP4_LENGTH,
|
||||
META_FLAME_MP4_LENGTH,
|
||||
META_FLAME_MP4_LENGTH_NO_SPACE,
|
||||
};
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>FFmpeg Unit Test</title>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../node_modules/chai/chai.js"></script>
|
||||
<script src="../dist/ffmpeg.dev.js"></script>
|
||||
<script src="./constants.js"></script>
|
||||
<script>mocha.setup('bdd');</script>
|
||||
<script src="./ffmpeg.test.js"></script>
|
||||
<script>
|
||||
window.expect = chai.expect;
|
||||
mocha.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,69 +0,0 @@
|
||||
const { createFFmpeg } = FFmpeg;
|
||||
|
||||
describe('FS()', () => {
|
||||
const ffmpeg = createFFmpeg(OPTIONS);
|
||||
before(async function cb() {
|
||||
this.timeout(0);
|
||||
await ffmpeg.load();
|
||||
});
|
||||
|
||||
it('should throw error when readdir for invalid path ', () => {
|
||||
expect(() => ffmpeg.FS('readdir', '/invalid')).to.throw(/readdir/);
|
||||
});
|
||||
it('should throw error when readFile for invalid path ', () => {
|
||||
expect(() => ffmpeg.FS('readFile', '/invalid')).to.throw(/readFile/);
|
||||
});
|
||||
it('should throw an default error ', () => {
|
||||
expect(() => ffmpeg.FS('unlink', '/invalid')).to.throw(/Oops/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('load()', () => {
|
||||
it('should throw error when corePath is not a string', async () => {
|
||||
const ffmpeg = createFFmpeg({ ...OPTIONS, corePath: null });
|
||||
|
||||
try {
|
||||
await ffmpeg.load();
|
||||
} catch (e) {
|
||||
expect(e).to.be.an('Error');
|
||||
}
|
||||
});
|
||||
it('should throw error when not called before FS() and run()', () => {
|
||||
const ffmpeg = createFFmpeg(OPTIONS);
|
||||
expect(() => ffmpeg.FS('readdir', 'dummy')).to.throw();
|
||||
expect(() => ffmpeg.run('-h')).to.throw();
|
||||
});
|
||||
|
||||
it('should throw error when running load() more than once', async () => {
|
||||
const ffmpeg = createFFmpeg(OPTIONS);
|
||||
await ffmpeg.load();
|
||||
try {
|
||||
await ffmpeg.load();
|
||||
} catch (e) {
|
||||
expect(e).to.be.an('Error');
|
||||
}
|
||||
}).timeout(TIMEOUT);
|
||||
});
|
||||
|
||||
describe('isLoaded()', () => {
|
||||
it('should return true when loaded', async () => {
|
||||
const ffmpeg = createFFmpeg(OPTIONS);
|
||||
await ffmpeg.load();
|
||||
expect(ffmpeg.isLoaded()).to.equal(true);
|
||||
}).timeout(TIMEOUT);
|
||||
});
|
||||
|
||||
describe('run()', () => {
|
||||
it('should not allow to run two command at the same time', async () => {
|
||||
const ffmpeg = createFFmpeg(OPTIONS);
|
||||
await ffmpeg.load();
|
||||
ffmpeg.run('-h');
|
||||
setTimeout(() => {
|
||||
try {
|
||||
ffmpeg.run('-h');
|
||||
} catch (e) {
|
||||
expect(e).to.be.an(Error);
|
||||
}
|
||||
}, 500);
|
||||
}).timeout(TIMEOUT);
|
||||
});
|
||||
Reference in New Issue
Block a user