/
input-value.cy.js
71 lines (64 loc) · 1.89 KB
/
input-value.cy.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/// <reference types="cypress" />
// @ts-check
import '../../src'
describe('Input element', () => {
it('types again if the value was corrupted', () => {
cy.visit('cypress/funky-input.html')
cy.get('#name')
.type('Cypress', { delay: 20 })
.if('not.have.value', 'Cypress')
.clear()
.type('Cypress')
.else()
.log('Input has expected value')
.finally()
.should('have.value', 'Cypress')
})
it('have.value positive', () => {
cy.wrap(Cypress.$('<input value="foo" >'))
.if('have.value', 'foo')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@if').should('be.calledOnce')
cy.get('@else').should('not.be.called')
})
it('have.value negative', () => {
cy.wrap(Cypress.$('<input value="foo" >'))
.if('have.value', 'bar')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@else').should('be.calledOnce')
cy.get('@if').should('not.be.called')
})
it('have.value positive', () => {
cy.wrap(Cypress.$('<input value="foo" >'))
.if('have.value', 'foo')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@if').should('be.calledOnce')
cy.get('@else').should('not.be.called')
})
context('not.have.value', () => {
it('positive', () => {
cy.wrap(Cypress.$('<input value="foo" >'))
.if('not.have.value', 'foo')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@else').should('be.calledOnce')
cy.get('@if').should('not.be.called')
})
it('negative', () => {
cy.wrap(Cypress.$('<input value="foo" >'))
.if('not.have.value', 'bar')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@if').should('be.calledOnce')
cy.get('@else').should('not.be.called')
})
})
})