diff --git a/packages/tc-api-rest-handlers/__tests__/absorb.spec.js b/packages/tc-api-rest-handlers/__tests__/absorb.spec.js index 91be9ce67..cafc7fd42 100644 --- a/packages/tc-api-rest-handlers/__tests__/absorb.spec.js +++ b/packages/tc-api-rest-handlers/__tests__/absorb.spec.js @@ -16,7 +16,7 @@ describe('rest POST (absorb)', () => { createNodes, createNode, connectNodes, - meta, + stockMetadata, getMetaPayload, } = setupMocks(namespace); @@ -132,7 +132,7 @@ describe('rest POST (absorb)', () => { metadata: getMetaPayload(), }); expect(status).toBe(200); - expect(body).toMatchObject(meta.update); + expect(body).toMatchObject(stockMetadata.update); await neo4jTest('SimpleGraphBranch', mainCode).exists(); await neo4jTest('SimpleGraphBranch', absorbedCode).notExists(); @@ -198,13 +198,13 @@ describe('rest POST (absorb)', () => { { type: 'HAS_LEAF', direction: 'outgoing', - props: meta.default, + props: stockMetadata.default, }, { type: 'SimpleGraphLeaf', props: { code: leafCode, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -231,13 +231,13 @@ describe('rest POST (absorb)', () => { { type: 'HAS_CHILD', direction: 'incoming', - props: meta.default, + props: stockMetadata.default, }, { type: 'SimpleGraphBranch', props: { code: parentCode, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -265,13 +265,13 @@ describe('rest POST (absorb)', () => { { type: 'HAS_LEAF', direction: 'outgoing', - props: meta.default, + props: stockMetadata.default, }, { type: 'SimpleGraphLeaf', props: { code: leafCode, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -324,13 +324,13 @@ describe('rest POST (absorb)', () => { { type: 'HAS_CHILD', direction: 'incoming', - props: meta.default, + props: stockMetadata.default, }, { type: 'SimpleGraphBranch', props: { code: `${namespace}-parent1`, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -360,12 +360,12 @@ describe('rest POST (absorb)', () => { body.leaves.forEach(relationship => expect(relationship).toMatchObject({ code: leafCode, - ...meta.default, + ...stockMetadata.default, }), ); expect(body.parent).toMatchObject({ code: parentCode, - ...meta.default, + ...stockMetadata.default, }); }); }); diff --git a/packages/tc-api-rest-handlers/__tests__/get.spec.js b/packages/tc-api-rest-handlers/__tests__/get.spec.js index eb7fdf008..0af9f84d7 100644 --- a/packages/tc-api-rest-handlers/__tests__/get.spec.js +++ b/packages/tc-api-rest-handlers/__tests__/get.spec.js @@ -10,7 +10,7 @@ describe('rest GET', () => { code: mainCode, }; - const { createNodes, createNode, connectNodes, meta } = setupMocks( + const { createNodes, createNode, connectNodes, stockMetadata } = setupMocks( namespace, ); @@ -30,7 +30,7 @@ describe('rest GET', () => { const { body, status } = await getHandler()(input); expect(status).toBe(200); - expect(body).toMatchObject(meta.default); + expect(body).toMatchObject(stockMetadata.default); }); it('retrieves array data', async () => { diff --git a/packages/tc-api-rest-handlers/__tests__/patch-diff.spec.js b/packages/tc-api-rest-handlers/__tests__/patch-diff.spec.js index aa94a443e..632130a05 100644 --- a/packages/tc-api-rest-handlers/__tests__/patch-diff.spec.js +++ b/packages/tc-api-rest-handlers/__tests__/patch-diff.spec.js @@ -49,9 +49,9 @@ describe('rest PATCH diff', () => { ); }); - it.skip("doesn't write if no real date changes detected"); - it.skip("doesn't write if no real datetime changes detected"); - it.skip("doesn't write if no real time changes detected"); + it.skip("doesn't write if no real date changes detected", () => {}); + it.skip("doesn't write if no real datetime changes detected", () => {}); + it.skip("doesn't write if no real time changes detected", () => {}); it('detects deleted property as a change', async () => { await createNode('KitchenSink', { @@ -198,7 +198,7 @@ describe('rest PATCH diff', () => { await connectNodes(main, 'HAD_LEAF', leaf1, { stringProperty: 'some string', }); - await connectNodes(main, 'HAS_LEAF', leaf2); + await connectNodes(main, 'HAD_LEAF', leaf2); const dbQuerySpy = spyDbQuery(); const { status } = await patch({ type: 'SimpleGraphBranch', diff --git a/packages/tc-api-rest-handlers/__tests__/patch-relationship-create.spec.js b/packages/tc-api-rest-handlers/__tests__/patch-relationship-create.spec.js index be9c35f5d..1266c386d 100644 --- a/packages/tc-api-rest-handlers/__tests__/patch-relationship-create.spec.js +++ b/packages/tc-api-rest-handlers/__tests__/patch-relationship-create.spec.js @@ -15,7 +15,7 @@ describe('rest PATCH relationship create', () => { createNodes, createNode, connectNodes, - meta, + stockMetadata, getMetaPayload, } = setupMocks(namespace); @@ -72,13 +72,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_FAVOURITE_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', props: { code: childCode, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -103,13 +103,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_FAVOURITE_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', props: { code: childCode, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -156,13 +156,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_FAVOURITE_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', props: { code: childCode2, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -200,13 +200,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_FAVOURITE_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', props: { code: childCode2, - ...meta.update, + ...stockMetadata.update, }, }, ); @@ -244,13 +244,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', props: { code: childCode2, - ...meta.update, + ...stockMetadata.update, }, }, ) @@ -258,13 +258,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.default, + props: stockMetadata.default, }, { type: 'ChildType', props: { code: childCode1, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -292,11 +292,11 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ); }); @@ -323,13 +323,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.default, + props: stockMetadata.default, }, { type: 'ChildType', props: { code: childCode1, - ...meta.default, + ...stockMetadata.default, }, }, ) @@ -337,13 +337,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', props: { code: childCode2, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -370,11 +370,11 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ); }); @@ -402,13 +402,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', props: { code: childCode2, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -441,13 +441,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_YOUNGER_SIBLING', direction: 'incoming', - props: meta.default, + props: stockMetadata.default, }, { type: 'MainType', props: { code: `${mainCode}-2`, - ...meta.default, + ...stockMetadata.default, }, }, ) @@ -455,13 +455,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_YOUNGER_SIBLING', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'MainType', props: { code: `${mainCode}-3`, - ...meta.default, + ...stockMetadata.default, }, }, ) @@ -469,11 +469,11 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.default, + props: stockMetadata.default, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ); }); @@ -504,13 +504,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_YOUNGER_SIBLING', direction: 'incoming', - props: meta.create, + props: stockMetadata.create, }, { type: 'MainType', props: { code: `${mainCode}-3`, - ...meta.default, + ...stockMetadata.default, }, }, ) @@ -518,13 +518,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_YOUNGER_SIBLING', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'MainType', props: { code: `${mainCode}-2`, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -569,13 +569,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', props: { code: childCode, - ...meta.create, + ...stockMetadata.create, }, }, ); @@ -601,13 +601,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', props: { code: childCode, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -652,8 +652,8 @@ describe('rest PATCH relationship create', () => { expect(status).toBe(200); expect(body).toMatchObject({ - children: [{ code: childCode, ...meta.create }], - parents: [{ code: parentCode, ...meta.create }], + children: [{ code: childCode, ...stockMetadata.create }], + parents: [{ code: parentCode, ...stockMetadata.create }], }); }); @@ -667,21 +667,24 @@ describe('rest PATCH relationship create', () => { expect(status).toBe(200); expect(body).toMatchObject({ - curiousChild: { ...childRelationshipProps, ...meta.create }, + curiousChild: { + ...childRelationshipProps, + ...stockMetadata.create, + }, }); await neo4jTest('MainType', mainCode) - .match(meta.update) + .match(stockMetadata.update) .hasRels(1) .hasRel( { type: 'HAS_CURIOUS_CHILD', direction: 'outgoing', - props: { someString, ...meta.create }, + props: { someString, ...stockMetadata.create }, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ); }); @@ -696,21 +699,28 @@ describe('rest PATCH relationship create', () => { expect(status).toBe(200); expect(body).toMatchObject({ - curiousChild: { ...childRelationshipTwoProps, ...meta.create }, + curiousChild: { + ...childRelationshipTwoProps, + ...stockMetadata.create, + }, }); await neo4jTest('MainType', mainCode) - .match(meta.update) + .match(stockMetadata.update) .hasRels(1) .hasRel( { type: 'HAS_CURIOUS_CHILD', direction: 'outgoing', - props: { someString, anotherString, ...meta.create }, + props: { + someString, + anotherString, + ...stockMetadata.create, + }, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ); }); @@ -734,34 +744,34 @@ describe('rest PATCH relationship create', () => { expect(status).toBe(200); expect(body).toMatchObject({ curiousParent: [ - { ...parentRelationshipProps, ...meta.create }, - { ...parent2RelationshipProps, ...meta.create }, + { ...parentRelationshipProps, ...stockMetadata.create }, + { ...parent2RelationshipProps, ...stockMetadata.create }, ], }); await neo4jTest('MainType', mainCode) - .match(meta.update) + .match(stockMetadata.update) .hasRels(2) .hasRel( { type: 'IS_CURIOUS_PARENT_OF', direction: 'incoming', - props: { someString, ...meta.create }, + props: { someString, ...stockMetadata.create }, }, { type: 'ParentType', - props: { code: parentCode, ...meta.default }, + props: { code: parentCode, ...stockMetadata.default }, }, ) .hasRel( { type: 'IS_CURIOUS_PARENT_OF', direction: 'incoming', - props: { anotherString, ...meta.create }, + props: { anotherString, ...stockMetadata.create }, }, { type: 'ParentType', - props: { code: parentCode2, ...meta.default }, + props: { code: parentCode2, ...stockMetadata.default }, }, ); }); @@ -784,33 +794,38 @@ describe('rest PATCH relationship create', () => { // curiousChild's hasMany value is false, curiousParent's hasMany value is true // Therefore in body, curiousParent is in an Array and curiousChild is not. expect(body).toMatchObject({ - curiousChild: { ...childRelationshipProps, ...meta.create }, - curiousParent: [{ ...parentRelationshipProps, ...meta.create }], + curiousChild: { + ...childRelationshipProps, + ...stockMetadata.create, + }, + curiousParent: [ + { ...parentRelationshipProps, ...stockMetadata.create }, + ], }); await neo4jTest('MainType', mainCode) - .match(meta.update) + .match(stockMetadata.update) .hasRels(2) .hasRel( { type: 'HAS_CURIOUS_CHILD', direction: 'outgoing', - props: { someString, ...meta.create }, + props: { someString, ...stockMetadata.create }, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ) .hasRel( { type: 'IS_CURIOUS_PARENT_OF', direction: 'incoming', - props: { someString, ...meta.create }, + props: { someString, ...stockMetadata.create }, }, { type: 'ParentType', - props: { code: parentCode, ...meta.default }, + props: { code: parentCode, ...stockMetadata.default }, }, ); }); @@ -833,33 +848,36 @@ describe('rest PATCH relationship create', () => { // curiousChild's hasMany value is false, curiousParent's hasMany value is true // Therefore in body, curiousParent is in an Array and curiousChild is not. expect(body).toMatchObject({ - curiousChild: { ...childRelationshipProps, ...meta.create }, - curiousParent: [{ code: parentCode, ...meta.create }], + curiousChild: { + ...childRelationshipProps, + ...stockMetadata.create, + }, + curiousParent: [{ code: parentCode, ...stockMetadata.create }], }); await neo4jTest('MainType', mainCode) - .match(meta.update) + .match(stockMetadata.update) .hasRels(2) .hasRel( { type: 'HAS_CURIOUS_CHILD', direction: 'outgoing', - props: { someString, ...meta.create }, + props: { someString, ...stockMetadata.create }, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ) .hasRel( { type: 'IS_CURIOUS_PARENT_OF', direction: 'incoming', - props: { ...meta.create }, + props: { ...stockMetadata.create }, }, { type: 'ParentType', - props: { code: parentCode, ...meta.default }, + props: { code: parentCode, ...stockMetadata.default }, }, ); }); @@ -894,13 +912,13 @@ describe('rest PATCH relationship create', () => { expect(status).toBe(200); expect(body).toMatchObject({ curiousParent: [ - { ...parentOneRelationshipProps, ...meta.create }, - { ...parentTwoRelationshipProps, ...meta.create }, + { ...parentOneRelationshipProps, ...stockMetadata.create }, + { ...parentTwoRelationshipProps, ...stockMetadata.create }, ], }); await neo4jTest('MainType', mainCode) - .match(meta.update) + .match(stockMetadata.update) .hasRels(2) .hasRel( { @@ -910,12 +928,12 @@ describe('rest PATCH relationship create', () => { someString: parentOneRelationshipProps.someString, anotherString: parentOneRelationshipProps.anotherString, - ...meta.create, + ...stockMetadata.create, }, }, { type: 'ParentType', - props: { code: parentCode, ...meta.default }, + props: { code: parentCode, ...stockMetadata.default }, }, ) .hasRel( @@ -925,12 +943,12 @@ describe('rest PATCH relationship create', () => { props: { someString, anotherString, - ...meta.create, + ...stockMetadata.create, }, }, { type: 'ParentType', - props: { code: parentCode2, ...meta.default }, + props: { code: parentCode2, ...stockMetadata.default }, }, ); }); @@ -967,12 +985,12 @@ describe('rest PATCH relationship create', () => { // curiousChild's hasMany value is false, curiousParent's hasMany value is true // Therefore in body, curiousParent is in an Array and curiousChild is not. expect(body).toMatchObject({ - curiousChild: { ...childRelProps, ...meta.create }, - curiousParent: [{ ...parentRelProps, ...meta.create }], + curiousChild: { ...childRelProps, ...stockMetadata.create }, + curiousParent: [{ ...parentRelProps, ...stockMetadata.create }], }); await neo4jTest('MainType', mainCode) - .match(meta.update) + .match(stockMetadata.update) .hasRels(2) .hasRel( { @@ -984,12 +1002,12 @@ describe('rest PATCH relationship create', () => { someMultipleChoice, someEnum, someBoolean, - ...meta.create, + ...stockMetadata.create, }, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ) .hasRel( @@ -999,12 +1017,12 @@ describe('rest PATCH relationship create', () => { props: { someString: parentRelProps.someString, anotherString: parentRelProps.anotherString, - ...meta.create, + ...stockMetadata.create, }, }, { type: 'ParentType', - props: { code: parentCode, ...meta.default }, + props: { code: parentCode, ...stockMetadata.default }, }, ); }); @@ -1024,12 +1042,12 @@ describe('rest PATCH relationship create', () => { curiousChild: { code: childCode, someMultipleChoice, - ...meta.create, + ...stockMetadata.create, }, }); await neo4jTest('MainType', mainCode) - .match(meta.update) + .match(stockMetadata.update) .hasRels(1) .hasRel( { @@ -1037,12 +1055,12 @@ describe('rest PATCH relationship create', () => { direction: 'outgoing', props: { someMultipleChoice, - ...meta.create, + ...stockMetadata.create, }, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ); }); @@ -1062,12 +1080,12 @@ describe('rest PATCH relationship create', () => { curiousChild: { code: childCode, someEnum, - ...meta.create, + ...stockMetadata.create, }, }); await neo4jTest('MainType', mainCode) - .match(meta.update) + .match(stockMetadata.update) .hasRels(1) .hasRel( { @@ -1075,12 +1093,12 @@ describe('rest PATCH relationship create', () => { direction: 'outgoing', props: { someEnum, - ...meta.create, + ...stockMetadata.create, }, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ); }); @@ -1100,12 +1118,12 @@ describe('rest PATCH relationship create', () => { curiousChild: { code: childCode, someBoolean, - ...meta.create, + ...stockMetadata.create, }, }); await neo4jTest('MainType', mainCode) - .match(meta.update) + .match(stockMetadata.update) .hasRels(1) .hasRel( { @@ -1113,12 +1131,12 @@ describe('rest PATCH relationship create', () => { direction: 'outgoing', props: { someBoolean, - ...meta.create, + ...stockMetadata.create, }, }, { type: 'ChildType', - props: { code: childCode, ...meta.default }, + props: { code: childCode, ...stockMetadata.default }, }, ); }); @@ -1141,7 +1159,9 @@ describe('rest PATCH relationship create', () => { 'Invalid property `notInSchema` on type `CuriousChild`.', }); - await neo4jTest('MainType', mainCode).match(meta.default).noRels(); + await neo4jTest('MainType', mainCode) + .match(stockMetadata.default) + .noRels(); }); it('create node related to nodes with strange codes', async () => { @@ -1170,13 +1190,13 @@ describe('rest PATCH relationship create', () => { { type: 'HAS_ODD_CODED_THING', direction: 'outgoing', - props: { oddString: 'blah', ...meta.create }, + props: { oddString: 'blah', ...stockMetadata.create }, }, { type: 'OddCodeType', props: { code: oddCode, - ...meta.create, + ...stockMetadata.create, }, }, ); diff --git a/packages/tc-api-rest-handlers/__tests__/patch-relationship-delete.spec.js b/packages/tc-api-rest-handlers/__tests__/patch-relationship-delete.spec.js index ccc7756d1..2a0e62e78 100644 --- a/packages/tc-api-rest-handlers/__tests__/patch-relationship-delete.spec.js +++ b/packages/tc-api-rest-handlers/__tests__/patch-relationship-delete.spec.js @@ -17,7 +17,7 @@ describe('rest PATCH relationship delete', () => { createNodes, createNode, connectNodes, - meta, + stockMetadata, getMetaPayload, } = setupMocks(namespace); @@ -122,13 +122,13 @@ describe('rest PATCH relationship delete', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.default, + props: stockMetadata.default, }, { type: 'ChildType', props: { code: childCode2, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -167,13 +167,13 @@ describe('rest PATCH relationship delete', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.default, + props: stockMetadata.default, }, { type: 'ChildType', props: { code: childCode1, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -204,13 +204,13 @@ describe('rest PATCH relationship delete', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.default, + props: stockMetadata.default, }, { type: 'ChildType', props: { code: childCode2, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -261,13 +261,13 @@ describe('rest PATCH relationship delete', () => { { type: 'HAS_YOUNGER_SIBLING', direction: 'incoming', - props: meta.default, + props: stockMetadata.default, }, { type: 'MainType', props: { code: `${mainCode}2`, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -295,13 +295,13 @@ describe('rest PATCH relationship delete', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'ChildType', props: { code: childCode2, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -386,13 +386,13 @@ describe('rest PATCH relationship delete', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.default, + props: stockMetadata.default, }, { type: 'ChildType', props: { code: childCode, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -427,13 +427,13 @@ describe('rest PATCH relationship delete', () => { { type: 'HAS_YOUNGER_SIBLING', direction: 'incoming', - props: meta.default, + props: stockMetadata.default, }, { type: 'MainType', props: { code: mainCode2, - ...meta.default, + ...stockMetadata.default, }, }, ) @@ -441,13 +441,13 @@ describe('rest PATCH relationship delete', () => { { type: 'HAS_CHILD', direction: 'outgoing', - props: meta.default, + props: stockMetadata.default, }, { type: 'ChildType', props: { code: childCode, - ...meta.default, + ...stockMetadata.default, }, }, ); diff --git a/packages/tc-api-rest-handlers/__tests__/patch-update.spec.js b/packages/tc-api-rest-handlers/__tests__/patch-update.spec.js index 1f30d0490..7a2f0f407 100644 --- a/packages/tc-api-rest-handlers/__tests__/patch-update.spec.js +++ b/packages/tc-api-rest-handlers/__tests__/patch-update.spec.js @@ -14,7 +14,7 @@ describe('rest PATCH update', () => { const { createNode, createNodes, - meta, + stockMetadata, getMetaPayload, connectNodes, } = setupMocks(namespace); @@ -81,10 +81,10 @@ describe('rest PATCH update', () => { ); expect(status).toBe(200); - expect(body).toMatchObject(meta.update); + expect(body).toMatchObject(stockMetadata.update); await neo4jTest('KitchenSink', mainCode) .exists() - .match(meta.update); + .match(stockMetadata.update); }); it('deletes a property as an update', async () => { await createKitchenSinkRecord({ @@ -440,7 +440,7 @@ describe('rest PATCH update', () => { }); await neo4jTest('SimpleGraphBranch', mainCode) - .match(meta.default) + .match(stockMetadata.default) .hasRels(1) .hasRel( { @@ -448,14 +448,14 @@ describe('rest PATCH update', () => { direction: 'outgoing', props: { stringProperty: 'new some string', - ...meta.update, + ...stockMetadata.update, }, }, { type: 'SimpleGraphLeaf', props: { code: leafCode, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -489,14 +489,14 @@ describe('rest PATCH update', () => { { type: 'HAD_LEAF', direction: 'outgoing', - props: meta.update, + props: stockMetadata.update, notProps: ['stringProperty'], }, { type: 'SimpleGraphLeaf', props: { code: leafCode, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -537,7 +537,7 @@ describe('rest PATCH update', () => { direction: 'outgoing', props: { stringProperty: 'some string', - ...meta.default, + ...stockMetadata.default, }, notProps: ['notInSchema'], }, @@ -545,7 +545,7 @@ describe('rest PATCH update', () => { type: 'SimpleGraphLeaf', props: { code: leafCode, - ...meta.default, + ...stockMetadata.default, }, }, ); diff --git a/packages/tc-api-rest-handlers/__tests__/post.spec.js b/packages/tc-api-rest-handlers/__tests__/post.spec.js index 8a6018b68..9b2c1ec4b 100644 --- a/packages/tc-api-rest-handlers/__tests__/post.spec.js +++ b/packages/tc-api-rest-handlers/__tests__/post.spec.js @@ -8,9 +8,12 @@ describe('rest POST', () => { const namespace = 'api-rest-handlers-post'; const branchCode = `${namespace}-branch`; - const { createNodes, createNode, meta, getMetaPayload } = setupMocks( - namespace, - ); + const { + createNodes, + createNode, + stockMetadata, + getMetaPayload, + } = setupMocks(namespace); describe('writing disconnected records', () => { const postKitchenSinkPayload = body => @@ -60,10 +63,10 @@ describe('rest POST', () => { }); expect(status).toBe(200); - expect(body).toMatchObject(meta.create); + expect(body).toMatchObject(stockMetadata.create); await neo4jTest('KitchenSink', branchCode) .exists() - .match(meta.create); + .match(stockMetadata.create); }); it('sets array data', async () => { @@ -243,7 +246,7 @@ describe('rest POST', () => { }); await neo4jTest('SimpleGraphBranch', branchCode) - .match(meta.create) + .match(stockMetadata.create) .notMatch({ leaves: [leafCode1], parent: branchCode2, @@ -253,24 +256,24 @@ describe('rest POST', () => { { type: 'HAS_LEAF', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'SimpleGraphLeaf', - props: { code: leafCode1, ...meta.default }, + props: { code: leafCode1, ...stockMetadata.default }, }, ) .hasRel( { type: 'HAS_CHILD', direction: 'incoming', - props: meta.create, + props: stockMetadata.create, }, { type: 'SimpleGraphBranch', props: { code: branchCode2, - ...meta.default, + ...stockMetadata.default, }, }, ); @@ -304,28 +307,28 @@ describe('rest POST', () => { }); await neo4jTest('SimpleGraphBranch', branchCode) - .match(meta.create) + .match(stockMetadata.create) .hasRels(2) .hasRel( { type: 'HAS_LEAF', direction: 'outgoing', - props: meta.create, + props: stockMetadata.create, }, { type: 'SimpleGraphLeaf', - props: { code: leafCode1, ...meta.create }, + props: { code: leafCode1, ...stockMetadata.create }, }, ) .hasRel( { type: 'HAS_CHILD', direction: 'incoming', - props: meta.create, + props: stockMetadata.create, }, { type: 'SimpleGraphBranch', - props: { code: branchCode2, ...meta.create }, + props: { code: branchCode2, ...stockMetadata.create }, }, ); }); @@ -351,8 +354,8 @@ describe('rest POST', () => { expect(status).toBe(200); expect(body).toMatchObject({ - leaves: [{ code: leafCode1, ...meta.create }], - parent: { code: branchCode2, ...meta.create }, + leaves: [{ code: leafCode1, ...stockMetadata.create }], + parent: { code: branchCode2, ...stockMetadata.create }, }); }); @@ -377,12 +380,12 @@ describe('rest POST', () => { formerBranch: { code: branchCode, ...relationshipDef, - ...meta.create, + ...stockMetadata.create, }, }); await neo4jTest('SimpleGraphLeaf', leafCode1) - .match(meta.create) + .match(stockMetadata.create) .hasRels(1) .hasRel( { @@ -390,12 +393,15 @@ describe('rest POST', () => { direction: 'incoming', props: { ...relationshipDef, - ...meta.create, + ...stockMetadata.create, }, }, { type: 'SimpleGraphBranch', - props: { code: branchCode, ...meta.create }, + props: { + code: branchCode, + ...stockMetadata.create, + }, }, ); }); @@ -428,39 +434,45 @@ describe('rest POST', () => { { code: leafCode1, ...relationshipDef1, - ...meta.create, + ...stockMetadata.create, }, { code: leafCode2, ...relationshipDef2, - ...meta.create, + ...stockMetadata.create, }, ], }); await neo4jTest('SimpleGraphBranch', branchCode) - .match(meta.create) + .match(stockMetadata.create) .hasRels(2) .hasRel( { type: 'HAD_LEAF', direction: 'outgoing', - props: { ...relationshipDef1, ...meta.create }, + props: { + ...relationshipDef1, + ...stockMetadata.create, + }, }, { type: 'SimpleGraphLeaf', - props: { code: leafCode1, ...meta.create }, + props: { code: leafCode1, ...stockMetadata.create }, }, ) .hasRel( { type: 'HAD_LEAF', direction: 'outgoing', - props: { ...relationshipDef2, ...meta.create }, + props: { + ...relationshipDef2, + ...stockMetadata.create, + }, }, { type: 'SimpleGraphLeaf', - props: { code: leafCode2, ...meta.create }, + props: { code: leafCode2, ...stockMetadata.create }, }, ); }); @@ -485,17 +497,20 @@ describe('rest POST', () => { }); await neo4jTest('SimpleGraphBranch', branchCode) - .match(meta.create) + .match(stockMetadata.create) .hasRels(1) .hasRel( { type: 'HAD_LEAF', direction: 'outgoing', - props: { ...relationshipDef, ...meta.create }, + props: { + ...relationshipDef, + ...stockMetadata.create, + }, }, { type: 'SimpleGraphLeaf', - props: { code: leafCode1, ...meta.create }, + props: { code: leafCode1, ...stockMetadata.create }, }, ); }); diff --git a/test-helpers/test-fixtures.js b/test-helpers/test-fixtures.js index a74fc7032..b77c7eeec 100644 --- a/test-helpers/test-fixtures.js +++ b/test-helpers/test-fixtures.js @@ -56,7 +56,7 @@ const fixtureBuilder = (namespace, now, then) => { ).toString(), }); - const meta = { + const stockMetadata = { default: Object.assign( getMetaObject('_updated', '-default', then), getMetaObject('_created', '-default', then), @@ -71,8 +71,8 @@ const fixtureBuilder = (namespace, now, then) => { ), }; - const createNode = getNodeCreator(namespace, meta.default); - const connect = getConnector(namespace, meta.default); + const createNode = getNodeCreator(namespace, stockMetadata.default); + const connect = getConnector(namespace, stockMetadata.default); const connectNodes = (...input) => { if (!Array.isArray(input[0])) { @@ -83,7 +83,13 @@ const fixtureBuilder = (namespace, now, then) => { const createNodes = (...nodes) => Promise.all(nodes.map(args => createNode(...args))); - return { createNodes, createNode, connectNodes, meta, getMetaPayload }; + return { + createNodes, + createNode, + connectNodes, + stockMetadata, + getMetaPayload, + }; }; const dropFixtures = namespace =>