39 lines
907 B
TypeScript
39 lines
907 B
TypeScript
import { expect, test } from "vitest";
|
|
import { extractHistoryTree } from "./utils";
|
|
|
|
const data = [
|
|
{
|
|
type: "ai_edit" as const,
|
|
code: "<html>3. edit with better icons and red text</html>",
|
|
inputs: {
|
|
prompt: "make text red",
|
|
},
|
|
},
|
|
{
|
|
type: "ai_edit" as const,
|
|
code: "<html>2. edit with better icons</html>",
|
|
inputs: {
|
|
prompt: "use better icons",
|
|
},
|
|
},
|
|
{
|
|
type: "ai_create" as const,
|
|
code: "<html>1. create</html>",
|
|
inputs: {
|
|
image_url: "",
|
|
},
|
|
},
|
|
];
|
|
|
|
test("should only include history from this point onward", () => {
|
|
expect(extractHistoryTree(data, 0)).toEqual([
|
|
"<html>1. create</html>",
|
|
"use better icons",
|
|
"<html>2. edit with better icons</html>",
|
|
"make text red",
|
|
"<html>3. edit with better icons and red text</html>",
|
|
]);
|
|
|
|
expect(extractHistoryTree(data, 2)).toEqual(["<html>1. create</html>"]);
|
|
});
|