fix tests
This commit is contained in:
parent
43107c6244
commit
9a3ec7386d
|
@ -2,6 +2,15 @@ import { expect, test, describe } from "vitest";
|
|||
import { get } from "svelte/store";
|
||||
import { addNode, resetNodes, makeFilterArgs, previewCommand } from "../../src/stores.js";
|
||||
|
||||
function makeFilter(name, type) {
|
||||
const [ins, outs] = type.toLowerCase().split("->");
|
||||
return {
|
||||
name: name,
|
||||
inputs: ins.split(""),
|
||||
outputs: outs.split(""),
|
||||
}
|
||||
}
|
||||
|
||||
describe("Filter param builder", () => {
|
||||
test("No params", () => {
|
||||
const results = makeFilterArgs({
|
||||
|
@ -56,7 +65,7 @@ describe("Command builder", () => {
|
|||
|
||||
test("Simple video filter", () => {
|
||||
resetNodes();
|
||||
addNode({ name: "filter", type: "V->V" }, "filter");
|
||||
addNode(makeFilter("filter", "V->V"), "filter");
|
||||
expect(get(previewCommand).join(" ")).toBe(
|
||||
`ffmpeg -i punch.mp4 -filter_complex "[0:v]filter[out_v]" -map "[out_v]" -map 0:a out.mp4`
|
||||
);
|
||||
|
@ -64,7 +73,7 @@ describe("Command builder", () => {
|
|||
|
||||
test("Simple audio filter", () => {
|
||||
resetNodes();
|
||||
addNode({ name: "filter", type: "A->A" }, "filter");
|
||||
addNode(makeFilter("filter", "a->a"), "filter");
|
||||
expect(get(previewCommand).join(" ")).toBe(
|
||||
`ffmpeg -i punch.mp4 -filter_complex "[0:a]filter[out_a]" -map "[out_a]" -map 0:v out.mp4`
|
||||
);
|
||||
|
@ -72,8 +81,8 @@ describe("Command builder", () => {
|
|||
|
||||
test("One audio, one video filter", () => {
|
||||
resetNodes();
|
||||
addNode({ name: "afilter", type: "A->A" }, "filter");
|
||||
addNode({ name: "vfilter", type: "V->V" }, "filter");
|
||||
addNode(makeFilter("afilter", "a->a"), "filter");
|
||||
addNode(makeFilter("vfilter", "v->v"), "filter");
|
||||
expect(get(previewCommand).join(" ")).toBe(
|
||||
`ffmpeg -i punch.mp4 -filter_complex "[0:a]afilter[out_a];[0:v]vfilter[out_v]" -map "[out_a]" -map "[out_v]" out.mp4`
|
||||
);
|
||||
|
@ -81,9 +90,9 @@ describe("Command builder", () => {
|
|||
|
||||
test("video filter chain", () => {
|
||||
resetNodes();
|
||||
addNode({ name: "vfilter", type: "V->V" }, "filter");
|
||||
addNode({ name: "vfilter2", type: "V->V" }, "filter");
|
||||
addNode({ name: "vfilter3", type: "V->V" }, "filter");
|
||||
addNode(makeFilter("vfilter", "v->v"), "filter");
|
||||
addNode(makeFilter("vfilter2", "v->v"), "filter");
|
||||
addNode(makeFilter("vfilter3", "v->v"), "filter");
|
||||
expect(get(previewCommand).join(" ")).toBe(
|
||||
`ffmpeg -i punch.mp4 -filter_complex "[0:v]vfilter,vfilter2,vfilter3[out_v]" -map "[out_v]" -map 0:a out.mp4`
|
||||
);
|
||||
|
@ -91,9 +100,9 @@ describe("Command builder", () => {
|
|||
|
||||
test("One audio, two video filters", () => {
|
||||
resetNodes();
|
||||
addNode({ name: "afilter", type: "A->A" }, "filter");
|
||||
addNode({ name: "vfilter", type: "V->V" }, "filter");
|
||||
addNode({ name: "vfilter2", type: "V->V" }, "filter");
|
||||
addNode(makeFilter("afilter", "a->a"), "filter");
|
||||
addNode(makeFilter("vfilter", "v->v"), "filter");
|
||||
addNode(makeFilter("vfilter2", "v->v"), "filter");
|
||||
expect(get(previewCommand).join(" ")).toBe(
|
||||
`ffmpeg -i punch.mp4 -filter_complex "[0:v]vfilter[1];[0:a]afilter[out_a];[1]vfilter2[out_v]" -map "[out_a]" -map "[out_v]" out.mp4`
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue