-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathEnzymeElement.js
More file actions
38 lines (32 loc) · 911 Bytes
/
EnzymeElement.js
File metadata and controls
38 lines (32 loc) · 911 Bytes
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
32
33
34
35
36
37
38
import assert from 'assert'
export class EnzymeElement {
constructor (wrapper, selector) {
this.wrapper = wrapper
this.selector = selector
}
async click () {
this.wrapper.find(this.selector).first()
.simulate('click')
// TODO submit only if action submit
.simulate('submit')
await this.wrapper.refresh()
}
async setValue (value) {
const input = this.wrapper.find(this.selector).first()
input.instance().value = value
input.simulate('change')
}
assertContentMatches (textToMatch) {
const foundText = this.wrapper.find(this.selector).text()
return assert(foundText.indexOf(textToMatch) > -1, `found ${foundText} instead of ${textToMatch}`)
}
_isVisible () {
return this.wrapper.find(this.selector).length > 0
}
assertIsVisible () {
assert(this._isVisible())
}
assertNotVisible () {
assert(!this._isVisible())
}
}