fix tests

This commit is contained in:
Sam Lavigne 2023-09-03 16:47:14 -04:00
parent 43107c6244
commit 9a3ec7386d
1 changed files with 19 additions and 10 deletions

View File

@ -2,6 +2,15 @@ import { expect, test, describe } from "vitest";
import { get } from "svelte/store"; import { get } from "svelte/store";
import { addNode, resetNodes, makeFilterArgs, previewCommand } from "../../src/stores.js"; 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", () => { describe("Filter param builder", () => {
test("No params", () => { test("No params", () => {
const results = makeFilterArgs({ const results = makeFilterArgs({
@ -56,7 +65,7 @@ describe("Command builder", () => {
test("Simple video filter", () => { test("Simple video filter", () => {
resetNodes(); resetNodes();
addNode({ name: "filter", type: "V->V" }, "filter"); addNode(makeFilter("filter", "V->V"), "filter");
expect(get(previewCommand).join(" ")).toBe( expect(get(previewCommand).join(" ")).toBe(
`ffmpeg -i punch.mp4 -filter_complex "[0:v]filter[out_v]" -map "[out_v]" -map 0:a out.mp4` `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", () => { test("Simple audio filter", () => {
resetNodes(); resetNodes();
addNode({ name: "filter", type: "A->A" }, "filter"); addNode(makeFilter("filter", "a->a"), "filter");
expect(get(previewCommand).join(" ")).toBe( expect(get(previewCommand).join(" ")).toBe(
`ffmpeg -i punch.mp4 -filter_complex "[0:a]filter[out_a]" -map "[out_a]" -map 0:v out.mp4` `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", () => { test("One audio, one video filter", () => {
resetNodes(); resetNodes();
addNode({ name: "afilter", type: "A->A" }, "filter"); addNode(makeFilter("afilter", "a->a"), "filter");
addNode({ name: "vfilter", type: "V->V" }, "filter"); addNode(makeFilter("vfilter", "v->v"), "filter");
expect(get(previewCommand).join(" ")).toBe( 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` `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", () => { test("video filter chain", () => {
resetNodes(); resetNodes();
addNode({ name: "vfilter", type: "V->V" }, "filter"); addNode(makeFilter("vfilter", "v->v"), "filter");
addNode({ name: "vfilter2", type: "V->V" }, "filter"); addNode(makeFilter("vfilter2", "v->v"), "filter");
addNode({ name: "vfilter3", type: "V->V" }, "filter"); addNode(makeFilter("vfilter3", "v->v"), "filter");
expect(get(previewCommand).join(" ")).toBe( 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` `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", () => { test("One audio, two video filters", () => {
resetNodes(); resetNodes();
addNode({ name: "afilter", type: "A->A" }, "filter"); addNode(makeFilter("afilter", "a->a"), "filter");
addNode({ name: "vfilter", type: "V->V" }, "filter"); addNode(makeFilter("vfilter", "v->v"), "filter");
addNode({ name: "vfilter2", type: "V->V" }, "filter"); addNode(makeFilter("vfilter2", "v->v"), "filter");
expect(get(previewCommand).join(" ")).toBe( 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` `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`
); );