updates tests and method names to getNewModelTemplate method
This commit is contained in:
parent
fb74982055
commit
b8a652e2ca
|
@ -115,7 +115,7 @@ export const newModel = (store, useRoot) => () => {
|
|||
? shadowHierarchy
|
||||
: getNode(shadowHierarchy, state.currentNode.nodeId)
|
||||
state.errors = []
|
||||
state.currentNode = templateApi(shadowHierarchy).getNewRecordTemplate(
|
||||
state.currentNode = templateApi(shadowHierarchy).getNewModelTemplate(
|
||||
parent,
|
||||
"",
|
||||
true
|
||||
|
|
|
@ -49,7 +49,7 @@ const nodeKeyMaker = node => () =>
|
|||
)(node)
|
||||
|
||||
const nodeNameMaker = node => () =>
|
||||
isRoot(node)
|
||||
isRoot(node)
|
||||
? "/"
|
||||
: joinKey(node.parent().nodeName(), node.name)
|
||||
|
||||
|
@ -165,7 +165,7 @@ export const getNewRootLevel = () =>
|
|||
nodeId: 0,
|
||||
})
|
||||
|
||||
const _getNewRecordTemplate = (parent, name, createDefaultIndex, isSingle) => {
|
||||
const _getNewModelTemplate = (parent, name, createDefaultIndex, isSingle) => {
|
||||
const nodeId = getNodeId(parent)
|
||||
const node = constructNode(parent, {
|
||||
name,
|
||||
|
@ -189,14 +189,14 @@ const _getNewRecordTemplate = (parent, name, createDefaultIndex, isSingle) => {
|
|||
return node
|
||||
}
|
||||
|
||||
export const getNewRecordTemplate = (
|
||||
export const getNewModelTemplate = (
|
||||
parent,
|
||||
name = "",
|
||||
createDefaultIndex = true
|
||||
) => _getNewRecordTemplate(parent, name, createDefaultIndex, false)
|
||||
) => _getNewModelTemplate(parent, name, createDefaultIndex, false)
|
||||
|
||||
export const getNewSingleRecordTemplate = parent =>
|
||||
_getNewRecordTemplate(parent, "", false, true)
|
||||
_getNewModelTemplate(parent, "", false, true)
|
||||
|
||||
export const getNewIndexTemplate = (parent, type = "ancestor") =>
|
||||
constructNode(parent, {
|
||||
|
@ -233,7 +233,7 @@ export const getNewAggregateTemplate = set => {
|
|||
|
||||
export default {
|
||||
getNewRootLevel,
|
||||
getNewRecordTemplate,
|
||||
getNewModelTemplate,
|
||||
getNewIndexTemplate,
|
||||
createNodeErrors,
|
||||
constructHierarchy,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
getNewRootLevel,
|
||||
getNewRecordTemplate,
|
||||
getNewModelTemplate,
|
||||
getNewIndexTemplate,
|
||||
createNodeErrors,
|
||||
constructHierarchy,
|
||||
|
@ -38,7 +38,7 @@ const api = app => ({
|
|||
getNewRootLevel,
|
||||
constructNode,
|
||||
getNewIndexTemplate,
|
||||
getNewRecordTemplate,
|
||||
getNewModelTemplate,
|
||||
getNewField,
|
||||
validateField,
|
||||
addField,
|
||||
|
|
|
@ -76,7 +76,7 @@ const setup = includeFish => setupApphierarchy(createApp(includeFish))
|
|||
const createApp = includeFish => templateApi => {
|
||||
const root = templateApi.getNewRootLevel()
|
||||
|
||||
const dogRecord = templateApi.getNewRecordTemplate(root, "dog")
|
||||
const dogRecord = templateApi.getNewModelTemplate(root, "dog")
|
||||
|
||||
const addField = recordNode => (name, type, typeOptions) => {
|
||||
const field = templateApi.getNewField(type)
|
||||
|
@ -97,7 +97,7 @@ const createApp = includeFish => templateApi => {
|
|||
|
||||
let fishStuff = {}
|
||||
if (includeFish) {
|
||||
const fishRecord = templateApi.getNewRecordTemplate(root, "fish")
|
||||
const fishRecord = templateApi.getNewModelTemplate(root, "fish")
|
||||
const addFishField = addField(fishRecord)
|
||||
addFishField("name", "string")
|
||||
addFishField("isAlive", "bool")
|
||||
|
|
|
@ -133,15 +133,15 @@ const setup = ({ parentCount, childCount, grandChildCount }) =>
|
|||
return field
|
||||
}
|
||||
|
||||
const parent = templateApi.getNewRecordTemplate(root, "parent")
|
||||
const parent = templateApi.getNewModelTemplate(root, "parent")
|
||||
parent.estimatedRecordCount = parentCount || 1000
|
||||
parent.collectionName = "parents"
|
||||
addField(parent)
|
||||
const child = templateApi.getNewRecordTemplate(parent, "child")
|
||||
const child = templateApi.getNewModelTemplate(parent, "child")
|
||||
child.estimatedRecordCount = childCount || 1000
|
||||
child.collectionName = "children"
|
||||
addField(child)
|
||||
const grandchild = templateApi.getNewRecordTemplate(child, "grandchild")
|
||||
const grandchild = templateApi.getNewModelTemplate(child, "grandchild")
|
||||
grandchild.estimatedRecordCount = grandChildCount || 1000
|
||||
grandchild.collectionName = "grandchildren"
|
||||
addField(grandchild)
|
||||
|
|
|
@ -42,7 +42,7 @@ export const getMemoryStore = () => setupDatastore(memory({}))
|
|||
export const getMemoryTemplateApi = store => {
|
||||
const app = {
|
||||
datastore: store || getMemoryStore(),
|
||||
publish: () => {},
|
||||
publish: () => { },
|
||||
getEpochTime: async () => new Date().getTime(),
|
||||
user: { name: "", permissions: [permission.writeTemplates.get()] },
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ export const appFromTempalteApi = async (
|
|||
const fullPermissions = generateFullPermissions(app)
|
||||
app.user.permissions = fullPermissions
|
||||
|
||||
if (disableCleanupTransactions) setCleanupFunc(app, async () => {})
|
||||
if (disableCleanupTransactions) setCleanupFunc(app, async () => { })
|
||||
else setCleanupFunc(app)
|
||||
|
||||
return app
|
||||
|
@ -138,15 +138,15 @@ export const hierarchyFactory = (...additionalFeatures) => templateApi => {
|
|||
const settingsRecord = templateApi.getNewSingleRecordTemplate(root)
|
||||
settingsRecord.name = "settings"
|
||||
|
||||
const customerRecord = templateApi.getNewRecordTemplate(root, "customer")
|
||||
const customerRecord = templateApi.getNewModelTemplate(root, "customer")
|
||||
customerRecord.collectionName = "customers"
|
||||
findCollectionDefaultIndex(customerRecord).map =
|
||||
"return {surname:record.surname, isalive:record.isalive, partner:record.partner};"
|
||||
|
||||
const partnerRecord = templateApi.getNewRecordTemplate(root, "partner")
|
||||
const partnerRecord = templateApi.getNewModelTemplate(root, "partner")
|
||||
partnerRecord.collectionName = "partners"
|
||||
|
||||
const partnerInvoiceRecord = templateApi.getNewRecordTemplate(
|
||||
const partnerInvoiceRecord = templateApi.getNewModelTemplate(
|
||||
partnerRecord,
|
||||
"invoice"
|
||||
)
|
||||
|
@ -154,7 +154,7 @@ export const hierarchyFactory = (...additionalFeatures) => templateApi => {
|
|||
findCollectionDefaultIndex(partnerInvoiceRecord).name =
|
||||
"partnerInvoices_index"
|
||||
|
||||
const invoiceRecord = templateApi.getNewRecordTemplate(
|
||||
const invoiceRecord = templateApi.getNewModelTemplate(
|
||||
customerRecord,
|
||||
"invoice"
|
||||
)
|
||||
|
@ -162,7 +162,7 @@ export const hierarchyFactory = (...additionalFeatures) => templateApi => {
|
|||
findCollectionDefaultIndex(invoiceRecord).map =
|
||||
"return {createdDate: record.createdDate, totalIncVat: record.totalIncVat};"
|
||||
|
||||
const chargeRecord = templateApi.getNewRecordTemplate(invoiceRecord, "charge")
|
||||
const chargeRecord = templateApi.getNewModelTemplate(invoiceRecord, "charge")
|
||||
chargeRecord.collectionName = "charges"
|
||||
|
||||
const hierarchy = {
|
||||
|
|
|
@ -16,10 +16,10 @@ describe("hierarchy node creation", () => {
|
|||
expect(root.nodeName()).toBe("/")
|
||||
})
|
||||
|
||||
it("> getNewRecordTemplate > should be initialise with correct members", async () => {
|
||||
it("> getNewModelTemplate > should be initialise with correct members", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const record = templateApi.getNewRecordTemplate(root)
|
||||
const record = templateApi.getNewModelTemplate(root)
|
||||
record.name = "child"
|
||||
expect(record.type).toBe("record")
|
||||
expect(record.children).toEqual([])
|
||||
|
@ -45,7 +45,7 @@ describe("hierarchy node creation", () => {
|
|||
expect(record.isSingle).toBe(true)
|
||||
})
|
||||
|
||||
it("> getNewrecordTemplate > should have static pathRegx if is singlerecord", async () => {
|
||||
it("> getNewModelTemplate > should have static pathRegx if is singlerecord", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const record = templateApi.getNewSingleRecordTemplate(root)
|
||||
|
@ -53,59 +53,59 @@ describe("hierarchy node creation", () => {
|
|||
expect(record.pathRegx()).toBe("/child")
|
||||
})
|
||||
|
||||
it("> getNewrecordTemplate > should add itself to parent records's children", async () => {
|
||||
it("> getNewModelTemplate > should add itself to parent records's children", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const parentRecord = templateApi.getNewRecordTemplate(root)
|
||||
const record = templateApi.getNewRecordTemplate(parentRecord)
|
||||
const parentRecord = templateApi.getNewModelTemplate(root)
|
||||
const record = templateApi.getNewModelTemplate(parentRecord)
|
||||
expect(parentRecord.children.length).toBe(1)
|
||||
expect(parentRecord.children[0]).toBe(record)
|
||||
})
|
||||
|
||||
it("> getNewrecordTemplate > child should get correct nodeName ", async () => {
|
||||
it("> getNewModelTemplate > child should get correct nodeName ", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const parentRecord = templateApi.getNewRecordTemplate(root)
|
||||
const parentRecord = templateApi.getNewModelTemplate(root)
|
||||
parentRecord.name = "parent"
|
||||
const record = templateApi.getNewRecordTemplate(parentRecord)
|
||||
const record = templateApi.getNewModelTemplate(parentRecord)
|
||||
record.name = "child"
|
||||
expect(record.nodeName()).toBe(`/${parentRecord.name}/${record.name}`)
|
||||
})
|
||||
|
||||
it("> getNewrecordTemplate > should add itself to parents's default index allowedNodeIds", async () => {
|
||||
it("> getNewModelTemplate > should add itself to parents's default index allowedNodeIds", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const parentRecord = templateApi.getNewRecordTemplate(root)
|
||||
const record = templateApi.getNewRecordTemplate(parentRecord)
|
||||
const parentRecord = templateApi.getNewModelTemplate(root)
|
||||
const record = templateApi.getNewModelTemplate(parentRecord)
|
||||
expect(root.indexes[0].allowedRecordNodeIds).toEqual([parentRecord.nodeId])
|
||||
expect(parentRecord.indexes[0].allowedRecordNodeIds).toEqual([
|
||||
record.nodeId,
|
||||
])
|
||||
})
|
||||
|
||||
it("> getNewrecordTemplate > should add itself to root's children", async () => {
|
||||
it("> getNewModelTemplate > should add itself to root's children", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const record = templateApi.getNewRecordTemplate(root)
|
||||
const record = templateApi.getNewModelTemplate(root)
|
||||
expect(root.children.length).toBe(1)
|
||||
expect(root.children[0]).toBe(record)
|
||||
})
|
||||
|
||||
it("> getNewrecordTemplate > should have dynamic pathRegx if parent is record", async () => {
|
||||
it("> getNewModelTemplate > should have dynamic pathRegx if parent is record", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const parent = templateApi.getNewRecordTemplate(root)
|
||||
const parent = templateApi.getNewModelTemplate(root)
|
||||
parent.collectionName = "customers"
|
||||
const record = templateApi.getNewRecordTemplate(parent)
|
||||
const record = templateApi.getNewModelTemplate(parent)
|
||||
record.name = "child"
|
||||
expect(record.pathRegx().startsWith("/customers")).toBe(true)
|
||||
expect(record.pathRegx().includes("[")).toBe(true)
|
||||
})
|
||||
|
||||
it("> getNewrecordTemplate > should add default index", async () => {
|
||||
it("> getNewModelTemplate > should add default index", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const record = templateApi.getNewRecordTemplate(root, "rec")
|
||||
const record = templateApi.getNewModelTemplate(root, "rec")
|
||||
expect(root.indexes.length).toBe(1)
|
||||
expect(root.indexes[0].name).toBe("rec_index")
|
||||
})
|
||||
|
@ -138,7 +138,7 @@ describe("hierarchy node creation", () => {
|
|||
it("> getNewIndexTemplate > should add itself to record indexes", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const record = templateApi.getNewRecordTemplate(root)
|
||||
const record = templateApi.getNewModelTemplate(root)
|
||||
const index = templateApi.getNewIndexTemplate(record)
|
||||
expect(record.indexes.length).toBe(1)
|
||||
expect(record.indexes[0]).toBe(index)
|
||||
|
@ -150,7 +150,7 @@ describe("hierarchy node creation", () => {
|
|||
expect(() => templateApi.getNewIndexTemplate()).toThrow(
|
||||
errors.allNonRootNodesMustHaveParent
|
||||
)
|
||||
expect(() => templateApi.getNewRecordTemplate()).toThrow(
|
||||
expect(() => templateApi.getNewModelTemplate()).toThrow(
|
||||
errors.allNonRootNodesMustHaveParent
|
||||
)
|
||||
})
|
||||
|
@ -158,8 +158,8 @@ describe("hierarchy node creation", () => {
|
|||
it("> adding node > should just add one (bugfix)", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const parent = templateApi.getNewRecordTemplate(root)
|
||||
templateApi.getNewRecordTemplate(parent)
|
||||
const parent = templateApi.getNewModelTemplate(root)
|
||||
templateApi.getNewModelTemplate(parent)
|
||||
|
||||
expect(root.children.length).toBe(1)
|
||||
expect(parent.children.length).toBe(1)
|
||||
|
@ -174,7 +174,7 @@ describe("hierarchy node creation", () => {
|
|||
it("> getNewAggregateGroupTemplate > should add itself to index aggregateGroups", async () => {
|
||||
const { templateApi } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const record = templateApi.getNewRecordTemplate(root)
|
||||
const record = templateApi.getNewModelTemplate(root)
|
||||
const index = templateApi.getNewIndexTemplate(record)
|
||||
const aggregateGroup = templateApi.getNewAggregateGroupTemplate(index)
|
||||
expect(index.aggregateGroups.length).toBe(1)
|
||||
|
|
|
@ -13,7 +13,7 @@ describe("diffHierarchy", () => {
|
|||
it("should detect root record created", async () => {
|
||||
const oldHierarchy = (await setup()).root;
|
||||
const newSetup = await setup()
|
||||
const opportunity = newSetup.templateApi.getNewRecordTemplate(newSetup.root, "opportunity", false)
|
||||
const opportunity = newSetup.templateApi.getNewModelTemplate(newSetup.root, "opportunity", false)
|
||||
const diff = diffHierarchy(oldHierarchy, newSetup.root)
|
||||
expect(diff).toEqual([{
|
||||
newNode: opportunity,
|
||||
|
@ -25,8 +25,8 @@ describe("diffHierarchy", () => {
|
|||
it("should only detect root record, when newly created root record has children ", async () => {
|
||||
const oldHierarchy = (await setup()).root;
|
||||
const newSetup = await setup()
|
||||
const opportunity = newSetup.templateApi.getNewRecordTemplate(newSetup.root, "opportunity", false)
|
||||
newSetup.templateApi.getNewRecordTemplate(opportunity, "invoice", true)
|
||||
const opportunity = newSetup.templateApi.getNewModelTemplate(newSetup.root, "opportunity", false)
|
||||
newSetup.templateApi.getNewModelTemplate(opportunity, "invoice", true)
|
||||
const diff = diffHierarchy(oldHierarchy, newSetup.root)
|
||||
expect(diff).toEqual([{
|
||||
newNode: opportunity,
|
||||
|
@ -38,7 +38,7 @@ describe("diffHierarchy", () => {
|
|||
it("should detect child record created", async () => {
|
||||
const oldHierarchy = (await setup()).root;
|
||||
const newSetup = await setup()
|
||||
const opportunity = newSetup.templateApi.getNewRecordTemplate(newSetup.contact, "opportunity", false)
|
||||
const opportunity = newSetup.templateApi.getNewModelTemplate(newSetup.contact, "opportunity", false)
|
||||
const diff = diffHierarchy(oldHierarchy, newSetup.root)
|
||||
expect(diff).toEqual([{
|
||||
newNode: opportunity,
|
||||
|
@ -98,7 +98,7 @@ describe("diffHierarchy", () => {
|
|||
it("should detect root record field removed", async () => {
|
||||
const oldSetup = await setup()
|
||||
const newSetup = await setup()
|
||||
newSetup.contact.fields = newSetup.contact.fields.filter(f => f.name !== "name")
|
||||
newSetup.contact.fields = newSetup.contact.fields.filter(f => f.name !== "name")
|
||||
const diff = diffHierarchy(oldSetup.root, newSetup.root)
|
||||
expect(diff).toEqual([{
|
||||
newNode: newSetup.contact,
|
||||
|
@ -110,7 +110,7 @@ describe("diffHierarchy", () => {
|
|||
it("should detect child record field removed", async () => {
|
||||
const oldSetup = await setup()
|
||||
const newSetup = await setup()
|
||||
newSetup.deal.fields = newSetup.deal.fields.filter(f => f.name !== "name")
|
||||
newSetup.deal.fields = newSetup.deal.fields.filter(f => f.name !== "name")
|
||||
const diff = diffHierarchy(oldSetup.root, newSetup.root)
|
||||
expect(diff).toEqual([{
|
||||
newNode: newSetup.deal,
|
||||
|
@ -140,7 +140,7 @@ describe("diffHierarchy", () => {
|
|||
const notesField = newSetup.templateApi.getNewField("string")
|
||||
notesField.name = "notes"
|
||||
newSetup.templateApi.addField(newSetup.contact, notesField)
|
||||
newSetup.contact.fields = newSetup.contact.fields.filter(f => f.name !== "name")
|
||||
newSetup.contact.fields = newSetup.contact.fields.filter(f => f.name !== "name")
|
||||
const diff = diffHierarchy(oldSetup.root, newSetup.root)
|
||||
expect(diff).toEqual([{
|
||||
newNode: newSetup.contact,
|
||||
|
@ -152,7 +152,7 @@ describe("diffHierarchy", () => {
|
|||
it("should detect root record estimated record count changed", async () => {
|
||||
const oldSetup = await setup()
|
||||
const newSetup = await setup()
|
||||
newSetup.contact.estimatedRecordCount = 987
|
||||
newSetup.contact.estimatedRecordCount = 987
|
||||
const diff = diffHierarchy(oldSetup.root, newSetup.root)
|
||||
expect(diff).toEqual([{
|
||||
newNode: newSetup.contact,
|
||||
|
@ -164,7 +164,7 @@ describe("diffHierarchy", () => {
|
|||
it("should detect root record estimated record count changed", async () => {
|
||||
const oldSetup = await setup()
|
||||
const newSetup = await setup()
|
||||
newSetup.deal.estimatedRecordCount = 987
|
||||
newSetup.deal.estimatedRecordCount = 987
|
||||
const diff = diffHierarchy(oldSetup.root, newSetup.root)
|
||||
expect(diff).toEqual([{
|
||||
newNode: newSetup.deal,
|
||||
|
|
|
@ -3,7 +3,7 @@ import { getMemoryTemplateApi } from "./specHelpers"
|
|||
import { fieldErrors } from "../src/templateApi/fields"
|
||||
|
||||
const getRecordTemplate = templateApi =>
|
||||
$(templateApi.getNewRootLevel(), [templateApi.getNewRecordTemplate])
|
||||
$(templateApi.getNewRootLevel(), [templateApi.getNewModelTemplate])
|
||||
|
||||
const getValidField = templateApi => {
|
||||
const field = templateApi.getNewField("string")
|
||||
|
|
|
@ -13,7 +13,7 @@ import { findCollectionDefaultIndex } from "./specHelpers"
|
|||
const createValidHierarchy = () => {
|
||||
const root = createNodes.getNewRootLevel()
|
||||
|
||||
const customerRecord = createNodes.getNewRecordTemplate(root, "customer")
|
||||
const customerRecord = createNodes.getNewModelTemplate(root, "customer")
|
||||
customerRecord.collectionName = "customers"
|
||||
|
||||
const customersDefaultIndex = findCollectionDefaultIndex(customerRecord)
|
||||
|
@ -27,7 +27,7 @@ const createValidHierarchy = () => {
|
|||
allCustomersOwedFunctions.aggregatedValue = "return record.owed"
|
||||
allCustomersOwedFunctions.name = "all customers owed amount"
|
||||
|
||||
const partnerRecord = createNodes.getNewRecordTemplate(root, "partner")
|
||||
const partnerRecord = createNodes.getNewModelTemplate(root, "partner")
|
||||
partnerRecord.collectionName = "partners"
|
||||
partnerRecord.name = "partner"
|
||||
const businessName = getNewField("string")
|
||||
|
|
|
@ -3,7 +3,7 @@ import { permission } from "../src/authApi/permissions"
|
|||
const saveThreeLevelHierarchy = async () => {
|
||||
const { templateApi, app } = await getMemoryTemplateApi()
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const record = templateApi.getNewRecordTemplate(root)
|
||||
const record = templateApi.getNewModelTemplate(root)
|
||||
record.name = "customer"
|
||||
const surname = templateApi.getNewField("string")
|
||||
surname.name = "surname"
|
||||
|
|
|
@ -166,7 +166,7 @@ describe("upgradeData", () => {
|
|||
leadField.name = "lead"
|
||||
leadField.type = "reference"
|
||||
leadField.typeOptions = {
|
||||
reverseIndexNodeKeys: [ newIndex.nodeKey() ],
|
||||
reverseIndexNodeKeys: [newIndex.nodeKey()],
|
||||
indexNodeKey: "/lead_index",
|
||||
displayValue: "name"
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ describe("upgradeData", () => {
|
|||
|
||||
it("should initialise a new root record", async () => {
|
||||
const { oldSetup, newSetup } = await configure()
|
||||
const invoice = newSetup.templateApi.getNewRecordTemplate(newSetup.root, "invoice", true)
|
||||
const invoice = newSetup.templateApi.getNewModelTemplate(newSetup.root, "invoice", true)
|
||||
invoice.collectionName = "invoices"
|
||||
|
||||
const nameField = newSetup.templateApi.getNewField("string")
|
||||
|
@ -207,7 +207,7 @@ describe("upgradeData", () => {
|
|||
|
||||
expect(itemsInNewIndex.length).toBe(0)
|
||||
|
||||
const newInvoice = _getNew(invoice, "/invoices")
|
||||
const newInvoice = _getNew(invoice, "/invoices")
|
||||
await _save(newSetup.app, newInvoice)
|
||||
|
||||
itemsInNewIndex = await _listItems(newSetup.app, "/invoice_index")
|
||||
|
@ -217,7 +217,7 @@ describe("upgradeData", () => {
|
|||
|
||||
it("should initialise a new child record", async () => {
|
||||
const { oldSetup, newSetup, records } = await configure()
|
||||
const invoice = newSetup.templateApi.getNewRecordTemplate(newSetup.contact, "invoice", true)
|
||||
const invoice = newSetup.templateApi.getNewModelTemplate(newSetup.contact, "invoice", true)
|
||||
invoice.collectionName = "invoices"
|
||||
|
||||
const nameField = newSetup.templateApi.getNewField("string")
|
||||
|
@ -230,7 +230,7 @@ describe("upgradeData", () => {
|
|||
|
||||
expect(itemsInNewIndex.length).toBe(0)
|
||||
|
||||
const newInvoice = _getNew(invoice, `${records.contact1.key}/invoices`)
|
||||
const newInvoice = _getNew(invoice, `${records.contact1.key}/invoices`)
|
||||
await _save(newSetup.app, newInvoice)
|
||||
|
||||
itemsInNewIndex = await _listItems(newSetup.app, `${records.contact1.key}/invoice_index`)
|
||||
|
|
|
@ -5,7 +5,7 @@ import { initialiseData } from "../src/appInitialise/initialiseData"
|
|||
export const setup = async store => {
|
||||
const { templateApi } = await getMemoryTemplateApi(store)
|
||||
const root = templateApi.getNewRootLevel()
|
||||
const contact = templateApi.getNewRecordTemplate(root, "contact", true)
|
||||
const contact = templateApi.getNewModelTemplate(root, "contact", true)
|
||||
contact.collectionName = "contacts"
|
||||
|
||||
const nameField = templateApi.getNewField("string")
|
||||
|
@ -16,9 +16,9 @@ export const setup = async store => {
|
|||
templateApi.addField(contact, nameField)
|
||||
templateApi.addField(contact, statusField)
|
||||
|
||||
const lead = templateApi.getNewRecordTemplate(root, "lead", true)
|
||||
const lead = templateApi.getNewModelTemplate(root, "lead", true)
|
||||
lead.collectionName = "leads"
|
||||
const deal = templateApi.getNewRecordTemplate(contact, "deal", true)
|
||||
const deal = templateApi.getNewModelTemplate(contact, "deal", true)
|
||||
deal.collectionName = "deals"
|
||||
|
||||
templateApi.addField(deal, { ...nameField })
|
||||
|
|
|
@ -20,7 +20,7 @@ export default async datastore => {
|
|||
const clients = templateApi.getNewCollectionTemplate(root)
|
||||
clients.name = "clients"
|
||||
|
||||
const client = templateApi.getNewRecordTemplate(clients)
|
||||
const client = templateApi.getNewModelTemplate(clients)
|
||||
client.name = "client"
|
||||
addStringField(client, "FamilyName")
|
||||
addStringField(client, "Address1")
|
||||
|
@ -33,7 +33,7 @@ export default async datastore => {
|
|||
const children = templateApi.getNewCollectionTemplate(client)
|
||||
children.name = "children"
|
||||
|
||||
const child = templateApi.getNewRecordTemplate(children)
|
||||
const child = templateApi.getNewModelTemplate(children)
|
||||
child.name = "child"
|
||||
addStringField(child, "FirstName")
|
||||
addStringField(child, "Surname")
|
||||
|
@ -43,7 +43,7 @@ export default async datastore => {
|
|||
const contacts = templateApi.getNewCollectionTemplate(client)
|
||||
contacts.name = "contacts"
|
||||
|
||||
const contact = templateApi.getNewRecordTemplate(contacts)
|
||||
const contact = templateApi.getNewModelTemplate(contacts)
|
||||
contact.name = "contact"
|
||||
addStringField(contact, "Name")
|
||||
addStringField(contact, "relationship")
|
||||
|
|
Loading…
Reference in New Issue