From b87366e7c8682fc58756a138687dcae10d347516 Mon Sep 17 00:00:00 2001 From: Ivan Kiral Date: Thu, 14 Mar 2024 09:36:36 +0100 Subject: [PATCH] add test for transformTaxonomyGroupModel --- .../sync/transformTaxonomyGroupModel.test.ts | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/unit/sync/transformTaxonomyGroupModel.test.ts diff --git a/tests/unit/sync/transformTaxonomyGroupModel.test.ts b/tests/unit/sync/transformTaxonomyGroupModel.test.ts new file mode 100644 index 00000000..d0f68f7a --- /dev/null +++ b/tests/unit/sync/transformTaxonomyGroupModel.test.ts @@ -0,0 +1,76 @@ +import { describe, expect, it } from "@jest/globals"; +import { TaxonomyContracts } from "@kontent-ai/management-sdk"; + +import { transformTaxonomyGroupsModel } from '../../../src/modules/sync/modelTransfomers/taxonomyGroups' + +const input: ReadonlyArray = [ + { + id: "taxonomyGroup!Id", + last_modified: "groupModified1", + name: "taxonomyGroup1", + codename: "taxonomy_group1", + external_id: "extId_taxonomy_group1", + terms: [ + { + id: "", + name: "nestedTerm", + codename: "nested_term", + last_modified: "nestedTermModofied", + terms: [] + } + ] + }, + { + id: "taxonomyGroup2Id", + last_modified: "groupModified2", + name: "taxonomyGroup2", + codename: "taxonomy_group2", + external_id: "extId_taxonomy_group2", + terms: [ + { + id: "", + name: "nestedTerm2", + codename: "nested_term2", + last_modified: "nestedTermModofied2", + external_id: "extId_nested_term2", + terms: [] + } + ] + }, +] + +describe("transformTaxonomyGroupsModel", () => { + it("transformTaxonomyGroupsModel", () => { + const result = transformTaxonomyGroupsModel(input); + + expect(result).toMatchInlineSnapshot(` +[ + { + "codename": "taxonomy_group1", + "external_id": "extId_taxonomy_group1", + "name": "taxonomyGroup1", + "terms": [ + { + "codename": "nested_term", + "name": "nestedTerm", + "terms": [], + }, + ], + }, + { + "codename": "taxonomy_group2", + "external_id": "extId_taxonomy_group2", + "name": "taxonomyGroup2", + "terms": [ + { + "codename": "nested_term2", + "external_id": "extId_nested_term2", + "name": "nestedTerm2", + "terms": [], + }, + ], + }, +] +`); + }) +}) \ No newline at end of file