enzyme at example

Solutions on MaxInterview for enzyme at example by the best coders in the world

showing results for - "enzyme at example"
Aymen
10 Mar 2018
1// dom.js
2
3import React from 'react'
4
5const DomTest = () => (
6  <div>
7    <div className='parentSatu'>
8      <p className='childSatu'>hello wordl satu</p>
9    </div>
10    <div className='parentDua'>
11      <p className='childDua'>hello wordl dua</p>
12    </div>
13    <div className='parentTiga'>
14      <p className='childTiga'>hello wordl tiga</p>
15    </div>
16
17    <div className='domGroup'>
18      <p className='domSatu satu'>DOM Satu</p>
19      <p className='domDua'>DOM Dua</p>
20      <p className='domTiga'>DOM Tiga</p>
21    </div>
22
23    <h1 className='header'>
24      <span className='sub-header'>Hello World</span>
25    </h1>
26  </div>
27)
28
29export default DomTest
30
31// dom.test.js
32
33test('find element in DomTest Component by index using at', () => {
34    expect(wrapper.find('.domGroup').children().at(0).text()).toStrictEqual('DOM Satu')
35    expect(wrapper.find('.domGroup').children().at(1).text()).toStrictEqual('DOM Dua')
36    expect(wrapper.find('.domGroup').children().at(2).text()).toStrictEqual('DOM Tiga')
37  })