From ccca59f03b5f139a8b8ded4de8b27bf46b072c81 Mon Sep 17 00:00:00 2001 From: Jiri Lojda Date: Mon, 2 Sep 2024 10:12:00 +0200 Subject: [PATCH] Use assetFoldersHandler in asset folder diff tests --- src/modules/sync/diff/assetFolder.ts | 2 +- tests/unit/syncModel/diff/assetFolder.test.ts | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/modules/sync/diff/assetFolder.ts b/src/modules/sync/diff/assetFolder.ts index f1dc6d8c..d17d2058 100644 --- a/src/modules/sync/diff/assetFolder.ts +++ b/src/modules/sync/diff/assetFolder.ts @@ -1,7 +1,7 @@ import { AssetFolderSyncModel } from "../types/syncModel.js"; import { baseHandler, Handler, makeArrayHandler, makeObjectHandler } from "./combinators.js"; -export const assetFolderHandler: Handler = makeObjectHandler({ +const assetFolderHandler: Handler = makeObjectHandler({ name: baseHandler, folders: { contextfulHandler: () => makeArrayHandler(f => f.codename, assetFolderHandler) }, }); diff --git a/tests/unit/syncModel/diff/assetFolder.test.ts b/tests/unit/syncModel/diff/assetFolder.test.ts index 2d78d312..ea7a0ae5 100644 --- a/tests/unit/syncModel/diff/assetFolder.test.ts +++ b/tests/unit/syncModel/diff/assetFolder.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import { assetFolderHandler } from "../../../../src/modules/sync/diff/assetFolder.js"; +import { assetFoldersHandler } from "../../../../src/modules/sync/diff/assetFolder.js"; import { AssetFolderSyncModel } from "../../../../src/modules/sync/types/syncModel.js"; const createFolder = ( @@ -15,41 +15,41 @@ const createFolder = ( describe("assetFolderHandler", () => { it("creates addInto operation for nested folders", () => { - const source = createFolder("root", [createFolder("folder1", [createFolder("folder2")])]); - const target = createFolder("root", [createFolder("folder1")]); + const source = [createFolder("root", [createFolder("folder1", [createFolder("folder2")])])]; + const target = [createFolder("root", [createFolder("folder1")])]; - const operations = assetFolderHandler(source, target); + const operations = assetFoldersHandler(source, target); expect(operations).toStrictEqual([ - { op: "addInto", path: "/folders/codename:folder1/folders", value: createFolder("folder2") }, + { op: "addInto", path: "/codename:root/folders/codename:folder1/folders", value: createFolder("folder2") }, ]); }); it("creates remove operation for nested folders", () => { - const source = createFolder("root", [createFolder("folder1")]); - const target = createFolder("root", [createFolder("folder1", [createFolder("folder2")])]); + const source = [createFolder("root", [createFolder("folder1")])]; + const target = [createFolder("root", [createFolder("folder1", [createFolder("folder2")])])]; - const operations = assetFolderHandler(source, target); + const operations = assetFoldersHandler(source, target); expect(operations).toStrictEqual([ { op: "remove", - path: "/folders/codename:folder1/folders/codename:folder2", + path: "/codename:root/folders/codename:folder1/folders/codename:folder2", oldValue: createFolder("folder2"), }, ]); }); it("creates replace operation for rename in nested folders", () => { - const source = createFolder("root", [createFolder("folder 1", [], "fCodename")]); - const target = createFolder("root", [createFolder("folder 2", [], "fCodename")]); + const source = [createFolder("root", [createFolder("folder 1", [], "fCodename")])]; + const target = [createFolder("root", [createFolder("folder 2", [], "fCodename")])]; - const operations = assetFolderHandler(source, target); + const operations = assetFoldersHandler(source, target); expect(operations).toStrictEqual([ { op: "replace", - path: "/folders/codename:fCodename/name", + path: "/codename:root/folders/codename:fCodename/name", value: "folder 1", oldValue: "folder 2", },