import { buildSlugRefsFromYaml } from '../../requests/config-as-code-requests/helpers/componentReferenceHelper'; import { MOCK_COMPONENT_ID } from '../fixtures/mocks'; describe('buildSlugRefsFromYaml', () => { it('builds component references input from a component yaml', () => { const cloudId = 'cloudId'; const componentYaml = { relationships: { DEPENDS_ON: ['slug1', 'slug2'], }, }; expect(buildSlugRefsFromYaml(cloudId, componentYaml)).toEqual([ { slug: { cloudId, slug: 'slug1' } }, { slug: { cloudId, slug: 'slug2' } }, ]); }); it('builds component references input from a component yaml containing both slugs and aris', () => { const cloudId = 'cloudId'; const componentYaml = { relationships: { DEPENDS_ON: [MOCK_COMPONENT_ID, 'slug2'], }, }; // Valid ARI is not included in slug refs output expect(buildSlugRefsFromYaml(cloudId, componentYaml)).toEqual([ { slug: { cloudId, slug: 'slug2' } }, ]); }); it('builds empty references input from a component yaml with no relationships', () => { const cloudId = 'cloudId'; const componentYaml = { relationships: {}, }; expect(buildSlugRefsFromYaml(cloudId, componentYaml)).toEqual([]); }); });