import * as React from 'react';
import { cleanup, render } from '@testing-library/react';
import { AttributeProxy } from '.';
describe('AttributeProxy component', () => {
afterEach(cleanup);
test('Empty render', () => {
const { container } = render(
);
expect(container.innerHTML).toBe('
');
});
test('Render only children', () => {
const { container } = render(
{'Some text'}
);
expect(container.textContent).toBe('Some text');
});
test('Render of a child with attributes', () => {
const { getByTitle } = render(
{'Some text'}
);
expect(getByTitle('this is title')).not.toBeNull();
});
test('Render of a child with class name', () => {
const { getByText } = render(
);
expect(getByText('Some text').classList.contains('someClass')).toBeTruthy();
});
test('Render from a child with a class, if there is one, then do not add a new one', () => {
const { getByText } = render(
{'Some text'}
);
expect(getByText('Some text').classList.length).toEqual(1);
});
test('Render with inline styles', () => {
const { getByText } = render(
{'Some text'}
);
expect(getByText('Some text').style.color).toBe('red');
});
});