1
0
Fork 0
mirror of synced 2024-09-10 06:26:02 +12:00
budibase/packages/core/test/templateApi.diffHierarchy.spec.js
2020-03-10 22:50:34 +00:00

34 lines
No EOL
1.1 KiB
JavaScript

import { getMemoryTemplateApi } from "./specHelpers"
import { diffHierarchy } from "../src/templateApi/diffHierarchy"
import { getFlattenedHierarchy } from "../src/templateApi/hierarchy"
describe("diffHierarchy", () => {
it("should not show any changes, when hierarchy is unchanged", async () => {
const oldHierarchy = (await setup()).root;
const newHierarchy = (await setup()).root;
const diff = diffHierarchy(oldHierarchy, newHierarchy)
expect(diff).toEqual([])
})
it("should detect record created", async () => {
})
})
const setup = async () => {
const { templateApi } = await getMemoryTemplateApi()
const root = templateApi.getNewRootLevel()
const contact = templateApi.getNewRecordTemplate(root, "contact", true)
const lead = templateApi.getNewRecordTemplate(root, "lead", true)
const deal = templateApi.getNewRecordTemplate(contact, "deal", true)
getFlattenedHierarchy(root)
return {
root, contact, lead, deal,
all_contacts: root.indexes[0],
all_leads: root.indexes[1],
deals_for_contacts: contact.indexes[0]
}
}