Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* Default rendered from*/
// <div>
// <form method="post">
// <div>
// <input name="file" type="file">
// </div>
// <input type="submit">
// </form>
// </div>
let form = TestUtils.findRenderedDOMComponentWithTag(component, 'form');
expect(ReactDom.findDOMNode(form).method).to.be.eql('post');
let inputContent = TestUtils.scryRenderedDOMComponentsWithTag(component, 'input');
expect(inputContent.length).to.be.eql(2);
expect(ReactDom.findDOMNode(inputContent[0]).type).to.be.eql('file');
expect(ReactDom.findDOMNode(inputContent[1]).type).to.be.eql('submit');
});
it('should generate correct class for modifier \'' + modifier + '\'', function() {
var element = React.createElement(ItemRepeater, { modifier: modifier }, data.map(function(datum) {
return React.createElement('p', { key: datum.key, style: { margin: 0 } }, datum.text);
}));
var component = TestUtils.renderIntoDocument(element);
var items = TestUtils.scryRenderedDOMComponentsWithTag(component, 'li');
var allMatch = _.every(items, function(item) {
return item.className === expectedClasses[i];
});
expect(allMatch).to.be.true;
})
});
it('should trigger close', function() {
var button = TestUtils.findRenderedDOMComponentWithTag(
modal, 'button'
);
TestUtils.Simulate.click(button);
var heading = TestUtils.findRenderedDOMComponentWithTag(
modal, 'h1'
);
expect(heading).toBeDefined();
var close = TestUtils.scryRenderedDOMComponentsWithTag(
modal, 'button'
)[1];
expect(onClose).not.toBeCalled();
TestUtils.Simulate.click(close);
expect(onClose).toBeCalled();
});
});
it("should navigate to image details page when user clicks on the image", function(){
var image = TestUtils.scryRenderedDOMComponentsWithTag(imageCardElement, "img");
TestUtils.Simulate.click(image[0]);
expect(navigator.navigateTo.calledOnce).toBe(true);
});
it('invokes callback when a button is clicked', () => {
let votedWith;
function vote(entry) { votedWith = entry; }
const component = renderIntoDocument(
);
const buttons = scryRenderedDOMComponentsWithTag(component, 'button');
Simulate.click(buttons[0]);
expect(votedWith).to.equal('Trainspotting');
});
it('highlights selected method and sends correct data on clicks', () => {
const initiallySelectedMethod = 'POST';
const onChange = jest.fn();
const component = TestUtils.renderIntoDocument(
);
const buttons = TestUtils.scryRenderedDOMComponentsWithTag(component, 'button');
const buttonNames = buttons.map(b => b.textContent);
expect(buttonNames).toEqual(MethodSwitcher.methods);
expect(getSelectedMethod(component)).toEqual(initiallySelectedMethod);
const putButton = findButtonWithMethod(buttons, 'PUT');
TestUtils.Simulate.click(putButton);
expect(onChange).toBeCalledWith(
{
target: {
name: 'method',
value: 'PUT',
},
});
});
export const createFinder = reactTree => query => {
if (typeof query !== 'string')
return scryRenderedComponentsWithType(reactTree, query)
else if (query.startsWith('.'))
return scryRenderedDOMComponentsWithClass(reactTree, query.substring(1))
else
return scryRenderedDOMComponentsWithTag(reactTree, query)
}
const pair = ['Trainspotting', '28 Days Later'];
const container = document.createElement('div');
let component = ReactDOM.render(
,
container
);
let firstButton = scryRenderedDOMComponentsWithTag(component, 'button')[0];
expect(firstButton.textContent).to.equal('Trainspotting');
pair[0] = 'Sunshine';
component = ReactDOM.render(
,
container
);
firstButton = scryRenderedDOMComponentsWithTag(component, 'button')[0];
expect(firstButton.textContent).to.equal('Trainspotting');
});
return talks._req.then(() => {
expect(talks.state.talks.results).toEqual(results);
var latest = TestUtils.scryRenderedDOMComponentsWithTag(talks, 'a')[0];
expect(latest.textContent).toEqual('Goto Latest Links');
})
});
beforeEach(() => {
flexbox = TestUtils.scryRenderedDOMComponentsWithTag(card, 'div')[0]
})