Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe.assuming(inBrowser(), 'only in browser')('react-decor-class', () => {
describe.assuming(inProduction(), 'only in production mode')('react contract regression tests', () => {
it('in production mode', () => {
// This test either passes or is ignored. It's here as a log artifact, to know whether other tests run in production mode
expect(process.env.NODE_ENV).to.eql('production');
});
});
const clientRenderer = new ClientRenderer();
afterEach(() => clientRenderer.cleanup());
function fooHook<p>>(_props: object, args: ElementArgs</p><p>) {
args.newProps['data-foo'] = 'foo';
return args;
}
function barHook</p><p>>(_props: object, args: ElementArgs</p><p>) {
args.newProps['data-bar'] = 'bar';
return args;
}
const fooDecorator = reactDecor.onEachElement(fooHook);
const barDecorator = reactDecor.onEachElement(barHook);
</p>
describe('', () => {
const clientRenderer = new ClientRenderer();
afterEach(() => clientRenderer.cleanup());
it('renders as a div by default', () => {
const {select} = clientRenderer.render();
expect(select(automationId)).to.be.instanceof(HTMLDivElement);
});
it('allows specifying the root tag element type', () => {
const {select} = clientRenderer.render();
expect(select(automationId)).to.be.instanceof(HTMLParagraphElement);
});
it('renders provided children', () => {
const {select} = clientRenderer.render(
describe('', () => {
const clientRenderer = new ClientRenderer();
afterEach(() => {
clientRenderer.cleanup();
});
describe('Component / Demo test', () => {
it('Basic demo', async () => {
const {driver, waitForDom} = clientRenderer.render().withDriver(CheckBoxDemoDriver);
const checkbox = driver.basicDemo.checkbox;
const button = driver.basicDemo.button;
await waitForDom(() => {
expect(checkbox.root, 'basic root').to.be.present();
expect(checkbox.isChecked(), 'expected checkbox to be unchecked').to.equal(false);
expect(checkbox.children[0], 'basic label').to.have.text(demoCheckBoxText);
describe.assuming(inBrowser(), 'only in browser')("disposable decorator", () => {
const clientRenderer = new ClientRenderer();
afterEach(() => runInContext(devMode.OFF, () => clientRenderer.cleanup()));
it('called on unmount', () => {
const spy = sinon.spy();
const {container} = clientRenderer.render(<div>);
clientRenderer.render(<div></div>, container);
expect(spy).to.have.callCount(0);
clientRenderer.render(<div>, container);
expect(spy).to.have.callCount(1);
});
});
</div></div>
describe('', () => {
const clientRenderer = new ClientRenderer();
afterEach(() => clientRenderer.cleanup());
const items = [
{label: 'Muffins'},
{label: 'Pancakes'},
{label: 'Waffles'}
];
it('renders a dropdown, opens it with a click, selects an item', async () => {
const {select, waitForDom} = clientRenderer.render();
await waitForDom(() => expect(select(dropDownDemo, list)).to.be.absent());
simulate.click(select(dropDownDemo, input));
await waitForDom(() => expect(select(dropDownDemo, list)).to.be.present());
describe('', () => {
const clientRenderer = new ClientRenderer();
afterEach(() => clientRenderer.cleanup());
const sampleItem = {label: 'label'};
const nestedItem: TreeItemData = treeData[0].children![1];
const allNodesLabels: string[] = getAllNodeLabels(treeData);
it('renders a tree view with a few children', async () => {
const {driver: treeViewDemo, waitForDom} = clientRenderer.render(
).withDriver(TreeViewDemoDriver);
const {treeView} = treeViewDemo;
await waitForDom(() => expect(treeView.root, 'demo not present').to.be.present());
describe(`render with ${position} position`, () => {
const clientRenderer = new ClientRenderer();
afterEach(() => clientRenderer.cleanup());
let driver: any;
let tooltipBounds: any;
let anchorBounds: any;
let tailBounds: any;
beforeEach(() => {
driver = renderWithProps(clientRenderer, {position});
tooltipBounds = driver.tooltipBounds;
anchorBounds = driver.anchorBounds;
tailBounds = driver.tailBounds;
});
if (expectations.positionTop) {
it('should be on the top', () => {
equal(anchorBounds.top, tooltipBounds.top + tooltipBounds.height - tooltipBounds.marginTop);
describe('', () => {
const clientRenderer = new ClientRenderer();
afterEach(() => clientRenderer.cleanup())
it('outputs an <h1> element by default', async () => {
const { select, waitForDom } =
clientRenderer.render(Test heading);
await waitForDom(() => {
const heading = select('HEADING');
expect(heading).to.be.present();
expect(heading).to.be.instanceOf(HTMLHeadingElement);
expect(heading!.tagName).to.equal('H1');
expect(heading).to.contain.text('Test heading');
});
});
['H1', 'H2', 'H3', 'H4', 'H5', 'H6'].forEach((headingType: any) => {</h1>
describe.assuming(inBrowser(), 'only in browser')('react root wrapper', () => {
const clientRenderer = new ClientRenderer();
afterEach(() => runInContext(devMode.OFF, () => clientRenderer.cleanup()));
it("works with empty SFC", () => {
const Comp = properties(() => <div data-automation-id="Root">);
const {select} = clientRenderer.render();
expect(select('Root')).to.be.ok;
});
it("works with empty class", () => {
@properties
class Comp extends React.Component {
render() {
return <div data-automation-id="Root">;
}</div></div>
describe('', () => {
const clientRenderer = new ClientRenderer();
beforeEach(() => {
environment = new WindowStub();
});
afterEach(() => {
environment.sandbox.restore();
});
afterEach(() => {
clientRenderer.cleanup();
});
describe('without any arguments', () => {
let select: (automationId: string) => HTMLElement | null;
let waitForDom: (expectation: () => void) => Promise;