import { generateId, removeElement, byId, insertHtml, createElement } from './assets/helpers';
import visible from '../visible';
const testID = generateId('Visible');
const sizeStyle = 'width: 10px; height: 10px;';
const visibleStyle = `${sizeStyle} opacity: 1;`;
describe('"visible"', () => {
beforeAll(() => insertHtml(`
`));
afterAll(() => removeElement(testID));
describe('Returns `false` when', () => {
it('DOM element is "display: none"', () => {
const node = byId('NoDisplay');
expect(visible(node)).toBe(false);
});
it('DOM element is a child of an element that is "display: none"', () => {
const node = byId('ChildDisplay');
expect(visible(node)).toBe(false);
});
it('DOM element is "visibility: hidden"', () => {
const node = byId('NotVisible');
expect(visible(node)).toBe(false);
});
it('DOM element is a child of an element that is "visibility: hidden"', () => {
const node = byId('ChildVisibility');
expect(visible(node)).toBe(false);
});
it('DOM element is Collapsed', () => {
const node = byId('Collapsed');
expect(visible(node)).toBe(false);
});
it('DOM element is a child of an element that is Collapsed', () => {
const node = byId('Collapsed');
const first = node.firstElementChild as HTMLElement;
expect(visible(first)).toBe(false);
});
it('DOM element is Transparent', () => {
const node = byId('Transparent');
expect(visible(node)).toBe(false);
});
it('DOM element is a child of an element that is Transparent', () => {
const node = byId('Transparent');
const first = node.firstElementChild as HTMLElement;
expect(visible(first)).toBe(false);
});
it('DOM element is not in the DOM', () => {
const node = createElement('div');
expect(visible(node)).toBe(false);
});
it('DOM element is a child of an element that is not in the DOM', () => {
const node = createElement('div');
node.innerHTML = '';
const first = node.firstElementChild as HTMLElement;
expect(visible(first)).toBe(false);
});
});
describe('Returns `true` when ', () => {
it('DOM element is in the DOM and is not styled invisible', () => {
const node = byId('Visible');
expect(visible(node)).toBe(true);
});
});
});