Reorg folders and use core as ffmpeg from now on
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);
|
||||
});
|
||||
34
packages/ffmpeg/tests/ffmpeg.test.ts
Normal file
34
packages/ffmpeg/tests/ffmpeg.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { FFmpegModule } from "..";
|
||||
import createFFmpeg from "..";
|
||||
|
||||
let core: FFmpegModule;
|
||||
|
||||
beforeAll(async () => {
|
||||
core = await createFFmpeg();
|
||||
});
|
||||
|
||||
describe("core", () => {
|
||||
test("core is ready", () => {
|
||||
expect(core).not.toBeUndefined();
|
||||
});
|
||||
|
||||
test("core functions are exported", () => {
|
||||
expect("NULL" in core).toBeTruthy();
|
||||
expect("SIZE_I32" in core).toBeTruthy();
|
||||
expect("exec" in core).toBeTruthy();
|
||||
expect("stringToPtr" in core).toBeTruthy();
|
||||
expect("stringsToPtr" in core).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("stringToPtr()", () => {
|
||||
test("convert a string to pointer", () => {
|
||||
expect(core.stringToPtr("string")).not.toBe(core.NULL);
|
||||
});
|
||||
});
|
||||
|
||||
describe("stringsToPtr()", () => {
|
||||
test("convert a string array to pointer", () => {
|
||||
expect(core.stringsToPtr(["string"])).not.toBe(core.NULL);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user