-
Notifications
You must be signed in to change notification settings - Fork 15
/
find-by-ref.jsx
31 lines (26 loc) · 993 Bytes
/
find-by-ref.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Note: you should use const createComponent = require('react-unit');
const createComponent = require('./react-unit');
const React = require('react');
const Bouviers = () =>
<div name="Jacqueline Bouvier" ref="bouvier">
<div name="Marge Bouvier" ref="bouvier">
<div name="Lisa Simpson" ref="simpson" />
</div>
<input name="Patty Bouvier" ref="bouvier" />
</div>;
describe('findByRef', () => {
it('should call the findBy method', () => {
const component = createComponent(<Bouviers/>);
spyOn(component, 'findBy');
component.findByRef('myRef');
expect(component.findBy).toHaveBeenCalled();
});
it('should find by ref attribute', () => {
const component = createComponent(<Bouviers/>);
const bouviers = component.findByRef('bouvier');
const simpsons = component.findByRef('simpson');
expect(bouviers.length).toEqual(3);
expect(simpsons.length).toEqual(1);
expect(simpsons[0].props.name).toEqual('Lisa Simpson');
});
});