Skip to content

Commit 288413b

Browse files
committed
Added test for mixin method & Updated README.md
1 parent 97abec6 commit 288413b

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,25 @@ Test(<TestComponent/>)
9494

9595
~~~
9696

97+
##mixin
98+
99+
Use `.mixin` if you want to add new middleware as methods to `Test`. This gives a more natural way of using middleware:
100+
101+
~~~js
102+
// In this example, CustomFind middleware was added to Test by mixin
103+
// and used if as it was a method on Test itself.
104+
105+
Test(<TestComponent />)
106+
.mixin({
107+
customFind: CustomFind
108+
})
109+
.customFind('cells', 'table td')
110+
.element('cells', cells => {
111+
expect(cells.length).to.be.equal(10)
112+
})
113+
114+
~~~
115+
116+
117+
97118
You can see more examples in the tests directory.

tests/mixin.jsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react'
2+
3+
import Test from '../src/legit-tests'
4+
import { Find } from '../src/middleware'
5+
import { expect } from 'chai'
6+
7+
import { TestComponent } from './components'
8+
9+
describe('Mixin method', () => {
10+
11+
it('should add Find as method to Test', () => {
12+
Test(<TestComponent/>)
13+
.mixin({
14+
customFind: Find
15+
})
16+
.customFind('div')
17+
.element('div', div => {
18+
expect(div.length).to.equal(2)
19+
})
20+
})
21+
22+
})

0 commit comments

Comments
 (0)