2022-12-04 22:38:56 +01:00
|
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
2021-05-23 13:13:18 +02:00
|
|
|
import { render } from '@testing-library/react'
|
2021-03-23 19:26:50 +01:00
|
|
|
import { Grid } from '../src/icons'
|
2020-12-02 13:48:39 +01:00
|
|
|
|
2022-12-04 22:38:56 +01:00
|
|
|
vi.mock('react-native-svg')
|
|
|
|
|
|
|
|
|
|
type Attributes = Record<string, { value: unknown}>
|
|
|
|
|
|
2020-12-02 13:48:39 +01:00
|
|
|
describe('Using lucide icon components', () => {
|
|
|
|
|
it('should render an component', () => {
|
2022-12-04 22:38:56 +01:00
|
|
|
const { container } = render(<Grid /> );
|
2020-12-02 13:48:39 +01:00
|
|
|
|
2021-05-23 13:13:18 +02:00
|
|
|
expect( container.innerHTML ).toMatchSnapshot();
|
2020-12-02 13:48:39 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should adjust the size, stroke color and stroke width', () => {
|
2021-05-23 13:13:18 +02:00
|
|
|
const testId = 'grid-icon';
|
|
|
|
|
const { container, getByTestId } = render(
|
2020-12-02 13:48:39 +01:00
|
|
|
<Grid
|
2021-05-23 13:13:18 +02:00
|
|
|
data-testid={testId}
|
2020-12-02 13:48:39 +01:00
|
|
|
size={48}
|
|
|
|
|
stroke="red"
|
|
|
|
|
strokeWidth={4}
|
|
|
|
|
/>,
|
|
|
|
|
);
|
|
|
|
|
|
2021-05-23 13:13:18 +02:00
|
|
|
const { attributes } = getByTestId(testId);
|
2022-12-04 22:38:56 +01:00
|
|
|
expect((attributes as unknown as Attributes).stroke.value).toBe('red');
|
|
|
|
|
expect((attributes as unknown as Attributes).width.value).toBe('48');
|
|
|
|
|
expect((attributes as unknown as Attributes).height.value).toBe('48');
|
|
|
|
|
expect((attributes as unknown as Attributes)['stroke-width'].value).toBe('4');
|
2021-05-23 13:13:18 +02:00
|
|
|
|
|
|
|
|
expect( container.innerHTML ).toMatchSnapshot();
|
2020-12-02 13:48:39 +01:00
|
|
|
});
|
|
|
|
|
})
|