From aaa9f151c4fd4084dc61cb08a2d1a89e4e410d6b Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Tue, 31 Oct 2023 08:30:23 -0600 Subject: [PATCH] test: add UT to cover new behavoir --- .../decomposedMetadataTransformer.test.ts | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/convert/transformers/decomposedMetadataTransformer.test.ts b/test/convert/transformers/decomposedMetadataTransformer.test.ts index 70e904c026..7e08a8ebb6 100644 --- a/test/convert/transformers/decomposedMetadataTransformer.test.ts +++ b/test/convert/transformers/decomposedMetadataTransformer.test.ts @@ -360,6 +360,55 @@ describe('DecomposedMetadataTransformer', () => { ]); }); + it('should merge unaddressableWithoutParent types with their parent, regardless of location', async () => { + const cot = DECOMPOSED_TOP_LEVEL_COMPONENT; + const cft = DECOMPOSED_TOP_LEVEL_COMPONENT; + const { type, fullName } = cot; + + const transformer = new DecomposedMetadataTransformer(); + const root = join('path', 'to', type.directoryName, fullName); + $$.SANDBOX.stub(cot, 'parseXml').resolves({ + CustomObjectTranslation: { + fields: [ + { name: 'child', test: 'testVal' }, + { name: 'child2', test: 'testVal2' }, + ], + }, + }); + + const result = await transformer.toSourceFormat(cft, cot); + + expect(result).to.deep.equal([ + { + source: new JsToXml({ + CustomFieldTranslation: { + [XML_NS_KEY]: XML_NS_URL, + name: 'child', + test: 'testVal', + }, + }), + output: join(root, 'child.fieldTranslation-meta.xml'), + }, + { + source: new JsToXml({ + CustomFieldTranslation: { + [XML_NS_KEY]: XML_NS_URL, + name: 'child2', + test: 'testVal2', + }, + }), + output: join(root, 'child2.fieldTranslation-meta.xml'), + }, + // the new parent was written + { + source: new JsToXml({ + [type.name]: '', + }), + output: join(root, 'myObject__c.objectTranslation-meta.xml'), + }, + ]); + }); + it('should handle decomposed parents with no files', async () => { const transformer = new DecomposedMetadataTransformer(); $$.SANDBOX.stub(component, 'parseXml').resolves({});