![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/node_modules/react-calendar/src/ |
import { describe, expect, it } from 'vitest';
import { render } from '@testing-library/react';
import Flex from './Flex.js';
describe('Flex', () => {
it('styles itself properly with wrap flag set to false', () => {
const { container } = render(
<Flex count={3} wrap={false}>
<div>Hey</div>
<div>Hi</div>
<div>Hello</div>
</Flex>,
);
const wrapper = container.firstElementChild;
expect(wrapper).toHaveStyle('display: flex');
expect(wrapper).toHaveStyle('flex-wrap: nowrap');
});
it('styles itself properly with wrap flag set to true', () => {
const { container } = render(
<Flex count={3} wrap>
<div>Hey</div>
<div>Hi</div>
<div>Hello</div>
</Flex>,
);
const wrapper = container.firstElementChild;
expect(wrapper).toHaveStyle('display: flex');
expect(wrapper).toHaveStyle('flex-wrap: wrap');
});
it('renders all given children', () => {
const { container } = render(
<Flex count={3}>
<div>Hey</div>
<div>Hi</div>
<div>Hello</div>
</Flex>,
);
const wrapper = container.firstElementChild as HTMLDivElement;
const children = wrapper.children;
expect(children).toHaveLength(3);
expect(children[0]).toHaveTextContent('Hey');
expect(children[1]).toHaveTextContent('Hi');
expect(children[2]).toHaveTextContent('Hello');
});
it('properly sizes and positions all the elements', () => {
const { container } = render(
<Flex count={3} offset={1}>
<div>Hey</div>
<div>Hi</div>
</Flex>,
);
const wrapper = container.firstElementChild as HTMLDivElement;
const children = Array.from(wrapper.children);
for (const child of children) {
expect(child).toHaveStyle('flex-basis: 33.333333333333336%');
expect(child).toHaveStyle('flex-shrink: 0');
expect(child).toHaveStyle('flex-grow: 0');
expect(child).toHaveStyle('overflow: hidden');
}
});
});