|
16 | 16 | import { basename, join } from 'node:path'; |
17 | 17 | import { createSandbox } from 'sinon'; |
18 | 18 | import { assert, expect } from 'chai'; |
19 | | -import { bundle, document, matchingContentFile, nestedTypes, xmlInFolder } from '../../mock'; |
| 19 | +import { bundle, digitalExperienceBundle, document, matchingContentFile, nestedTypes, xmlInFolder } from '../../mock'; |
20 | 20 | import { DefaultMetadataTransformer } from '../../../src/convert/transformers/defaultMetadataTransformer'; |
21 | 21 | import { registry, RegistryAccess, SourceComponent, VirtualTreeContainer, WriteInfo } from '../../../src'; |
22 | 22 | import { TestReadable } from '../../mock/convert/readables'; |
@@ -296,8 +296,25 @@ describe('DefaultMetadataTransformer', () => { |
296 | 296 | expect(await transformer.toSourceFormat({ component })).to.deep.equal(expectedInfos); |
297 | 297 | }); |
298 | 298 |
|
| 299 | + it.only('should merge mobile.json into mobile/mobile.json', async () => { |
| 300 | + const component = SourceComponent.createVirtualComponent(digitalExperienceBundle.DE_COMPONENT_PROPERTIES, [ |
| 301 | + { |
| 302 | + dirPath: digitalExperienceBundle.HOME_VIEW_PATH, |
| 303 | + children: [digitalExperienceBundle.HOME_VIEW_MOBILE_VARIANT_FILE], |
| 304 | + }, |
| 305 | + ]); |
| 306 | + const mergeWith = digitalExperienceBundle.DE_COMPONENT; |
| 307 | + |
| 308 | + assert(typeof mergeWith.content === 'string'); |
| 309 | + const transformed = await transformer.toSourceFormat({ component, mergeWith }); |
| 310 | + const expected = { |
| 311 | + source: component.tree.stream(join(digitalExperienceBundle.DE_COMPONENT_PROPERTIES.content, 'mobile.json')), |
| 312 | + output: join(mergeWith.content, 'home', 'mobile.json'), |
| 313 | + }; |
| 314 | + expect(transformed).to.deep.include(expected); |
| 315 | + }); |
| 316 | + |
299 | 317 | it('should merge output with merge component when content is a directory', async () => { |
300 | | - assert(typeof bundle.COMPONENT.name === 'string'); |
301 | 318 | const root = join('path', 'to', 'another', bundle.COMPONENT.type.directoryName, bundle.COMPONENT.name); |
302 | 319 | const component = SourceComponent.createVirtualComponent( |
303 | 320 | { |
|
0 commit comments