Skip to content

Commit

Permalink
add test for transformTaxonomyGroupModel
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanKiral committed Mar 14, 2024
1 parent 5586e89 commit b87366e
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions tests/unit/sync/transformTaxonomyGroupModel.test.ts
Original file line number Diff line number Diff line change
@@ -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<TaxonomyContracts.ITaxonomyContract> = [
{
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": [],
},
],
},
]
`);
})
})

0 comments on commit b87366e

Please sign in to comment.