import { render as enzymeRender, mount } from 'enzyme';
import { render, screen } from '@testing-library/react';
import List from '../index';
const types = {
size: ['small', undefined],
};
describe('List component', () => {
/* eslint-disable no-restricted-syntax */
for (const type in types) {
if (Object.prototype.hasOwnProperty.call(types, type)) {
// eslint-disable-next-line array-callback-return
types[type].map(variantType => {
it(`${type}-${variantType}-default`, () => {
const prop = { [type]: variantType };
expect(
enzymeRender(
{({ Item, getProps }) => - hello
}
)
).toMatchSnapshot();
});
it(`${type}-${variantType}-with icon`, () => {
const prop = { [type]: variantType };
expect(
enzymeRender(
{({ Item, getProps }) => (
)}
)
).toMatchSnapshot();
});
it(`${type}-${variantType}-use unique as key`, () => {
const prop = { [type]: variantType };
const data = [{ id: 'a' }, { id: 'b' }, { id: 'c' }, { id: 'd' }];
const comp = mount(
{({ Item, getProps }) => }
);
comp.find('LI').forEach((wrapper, i) => {
expect(wrapper.key()).toEqual(data[i].id);
});
});
it(`${type}-${variantType}-hoverable`, () => {
const prop = { [type]: variantType };
const data = [{ id: 'a' }, { id: 'b' }, { id: 'c' }, { id: 'd' }];
render(
{({ Item, getProps }) => }
);
const listItem = screen.getAllByRole('listitem').at(2);
expect(listItem).toMatchSnapshot();
});
});
}
}
});