Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should render before table', inject(function(components, injector) {
// given
components.onGetComponent('table.before', () => () => <div></div>);
// when
const renderedTree = renderIntoDocument();
// then
expect(findRenderedDOMElementWithClass(renderedTree, 'before')).to.exist;
}));
it('should render after table', inject(function(components, injector) {
// given
components.onGetComponent('table.after', () => () => <div></div>);
// when
const renderedTree = renderIntoDocument();
// then
expect(findRenderedDOMElementWithClass(renderedTree, 'after')).to.exist;
}));
it('should render table', inject(function(injector) {
// when
const renderedTree = renderIntoDocument();
// then
const node = findRenderedDOMElementWithClass(renderedTree, 'tjs-table');
expect(node).to.exist;
}));
it('unless autoFocus=false', inject(function(contextMenu) {
// when
contextMenu.open(null, {
autoFocus: false
});
// then
var inputEl = findRenderedDOMElementWithClass(renderedTree, 'test-input');
expect(
document.activeElement
).not.to.equal(inputEl);
}));
it('should render head, body & foot', inject(function(components, injector) {
// given
components.onGetComponent('table.head', () => () => );
components.onGetComponent('table.body', () => () => );
components.onGetComponent('table.foot', () => () => );
// when
const renderedTree = renderIntoDocument();
// then
expect(findRenderedDOMElementWithClass(renderedTree, 'head')).to.exist;
expect(findRenderedDOMElementWithClass(renderedTree, 'body')).to.exist;
expect(findRenderedDOMElementWithClass(renderedTree, 'foot')).to.exist;
}));
// given
const WithContext = withContext(ContextMenuComponent, {
injector,
eventBus
});
const renderedTree = renderIntoDocument();
components.onGetComponent('context-menu', () => () => <div></div>);
// when
contextMenu.open();
// then
expect(findRenderedDOMElementWithClass(renderedTree, 'context-menu')).to.exist;
expect(findRenderedDOMElementWithClass(renderedTree, 'foo')).to.exist;
}
));
function(contextMenu) {
// given
contextMenu.open();
const element = findRenderedDOMElementWithClass(renderedTree, 'context-menu');
// when
triggerMouseEvent(element, 'mousedown');
triggerMouseEvent(document.body, 'mouseup');
triggerMouseEvent(document.body, 'click');
// then
expect(
findRenderedDOMElementWithClass(renderedTree, 'context-menu')
).to.exist;
})
);
);
}
const injector = createInjector({
eventBus: new EventBus()
});
// when
const tree = mount(
);
// then
const node = findRenderedDOMElementWithClass(tree, 'cell');
expect(node).to.exist;
expect(node.autofocus).to.be.true;
expect(matches(node, '.selected')).to.be.false;
// node selection changed
injector.get('eventBus').fire('selection.foo.changed', { selected: true });
expect(matches(node, '.selected')).to.be.true;
expect(matches(node, '.selected-secondary')).to.be.false;
injector.get('eventBus').fire('selection.foo.changed', {
selected: false,
selectedSecondary: true
});
const WithContext = withContext(ContextMenuComponent, {
injector,
eventBus
});
const renderedTree = renderIntoDocument();
components.onGetComponent('context-menu', () => () => <div></div>);
contextMenu.open();
// when
contextMenu.close();
// then
const node = findRenderedDOMElementWithClass(renderedTree, 'context-menu');
expect(node).to.not.exist;
}
));
function(contextMenu) {
// given
contextMenu.open();
const element = findRenderedDOMElementWithClass(renderedTree, 'context-menu');
// when
triggerMouseEvent(element, 'mousedown');
triggerMouseEvent(document.body, 'mouseup');
triggerMouseEvent(document.body, 'click');
// then
expect(
findRenderedDOMElementWithClass(renderedTree, 'context-menu')
).to.exist;
})
);