-
Notifications
You must be signed in to change notification settings - Fork 12
/
alias.cy.js
54 lines (49 loc) · 1.37 KB
/
alias.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
/// <reference types="cypress" />
// @ts-check
import '../../src'
describe('aliases', () => {
it('has an existing alias', () => {
cy.wrap(42).as('answer')
cy.get('@answer')
.if('exist')
.log('alias exists')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@if').should('have.been.called')
cy.get('@else').should('not.have.been.called')
})
it('has an existing alias no arguments', () => {
cy.wrap(42).as('answer')
cy.get('@answer')
.if()
.log('alias exists')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@if').should('have.been.called')
cy.get('@else').should('not.have.been.called')
})
it('has no alias', () => {
// notice there is no alias with the name "answer"
cy.get('@answer')
.if()
.log('alias exists')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@else').should('have.been.called')
cy.get('@if').should('not.have.been.called')
})
it('alias has null value is treated as non-existent', () => {
cy.wrap(null).as('nullAlias')
cy.get('@nullAlias')
.if()
.log('alias exists')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@else').should('have.been.called')
cy.get('@if').should('not.have.been.called')
})
})