2021-12-01 22:10:51 +01:00
|
|
|
import * as React from 'react';
|
2023-04-24 12:21:37 +02:00
|
|
|
import { screen } from '@testing-library/react';
|
|
|
|
import configureMockStore from 'redux-mock-store';
|
|
|
|
import thunk from 'redux-thunk';
|
|
|
|
import { renderWithProvider } from '../../../../../test/lib/render-helpers';
|
|
|
|
import mockState from '../../../../../test/data/mock-state.json';
|
2021-12-01 22:10:51 +01:00
|
|
|
import SnapSettingsCard from '.';
|
|
|
|
|
|
|
|
describe('SnapSettingsCard', () => {
|
|
|
|
const args = {
|
|
|
|
name: 'Snap name',
|
2023-04-24 12:21:37 +02:00
|
|
|
packageName: '@metamask/test-snap-bip44',
|
|
|
|
snapId: 'npm:@metamask/test-snap-bip44',
|
|
|
|
onClick: () => null,
|
2021-12-01 22:10:51 +01:00
|
|
|
};
|
2023-04-24 12:21:37 +02:00
|
|
|
const mockStore = configureMockStore([thunk])(mockState);
|
|
|
|
|
2021-12-01 22:10:51 +01:00
|
|
|
it('should render the SnapsSettingCard without crashing', () => {
|
2023-04-24 12:21:37 +02:00
|
|
|
const { getByText } = renderWithProvider(
|
|
|
|
<SnapSettingsCard {...args} />,
|
|
|
|
mockStore,
|
|
|
|
);
|
2021-12-01 22:10:51 +01:00
|
|
|
expect(getByText('Snap name')).toBeDefined();
|
|
|
|
});
|
|
|
|
|
2023-04-24 12:21:37 +02:00
|
|
|
it('should render the icon fallback using the first letter of the name', async () => {
|
|
|
|
const { getByText } = renderWithProvider(
|
|
|
|
<SnapSettingsCard {...args} icon="" />,
|
|
|
|
mockStore,
|
2021-12-01 22:10:51 +01:00
|
|
|
);
|
|
|
|
|
2023-04-24 12:21:37 +02:00
|
|
|
const avatar = await screen.findAllByText(/B/u);
|
|
|
|
avatar.forEach((avatarBaseElement) => {
|
|
|
|
expect(avatarBaseElement).toHaveClass('mm-avatar-base');
|
|
|
|
});
|
|
|
|
expect(getByText('B')).toBeDefined();
|
2021-12-01 22:10:51 +01:00
|
|
|
});
|
|
|
|
|
2023-04-24 12:21:37 +02:00
|
|
|
it('should render the package name', () => {
|
|
|
|
const { getByText } = renderWithProvider(
|
|
|
|
<SnapSettingsCard {...args} icon="" />,
|
|
|
|
mockStore,
|
|
|
|
);
|
|
|
|
expect(getByText('@metamask/test-snap-bip44')).toBeDefined();
|
2021-12-01 22:10:51 +01:00
|
|
|
});
|
|
|
|
});
|