Skip to content

Commit

Permalink
feat: add arrow to asset name #2551
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuralidharreddy authored and chejimmy committed Feb 28, 2024
1 parent 7578a2e commit bd12bea
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import { AssetTableNameLink } from './assetTableNameLink';

test('renders Link component with correct ariaLabel and onFollow event', () => {
const assetId = '123';
const assetName = 'Demo Asset Wind Farm';
const updateParentAssetId = jest.fn();

const { getByText, getByTestId } = render(
<AssetTableNameLink
assetId={assetId}
assetName={assetName}
updateParentAssetId={updateParentAssetId}
/>
);
const link = getByText(assetName);

expect(link).toBeInTheDocument();

const linkText = getByTestId('asset-name-link');
expect(linkText).toHaveAttribute(
'title',
`View children assets of ${assetName}`
);

fireEvent.click(link);
expect(updateParentAssetId).toHaveBeenCalledWith(assetId);
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Link from '@cloudscape-design/components/link';
import React from 'react';

import { Link, Icon } from '@cloudscape-design/components';
import { spaceScaledXs } from '@cloudscape-design/design-tokens';

export interface AssetTableNameLinkProps {
assetId: string;
assetName: string;
Expand All @@ -20,7 +22,13 @@ export function AssetTableNameLink({
updateParentAssetId(assetId);
}}
>
{assetName}
<span
data-testid='asset-name-link'
title={`View children assets of ${assetName}`}
>
<Icon name='angle-right' size='inherit' />
<span style={{ paddingLeft: spaceScaledXs }}>{assetName}</span>
</span>
</Link>
);
}

0 comments on commit bd12bea

Please sign in to comment.