-
Notifications
You must be signed in to change notification settings - Fork 2
/
type.cy.js
27 lines (24 loc) · 911 Bytes
/
type.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
// @ts-check
/// <reference path="../../commands/index.d.ts" />
import '../../commands/type'
it('types the alias only', () => {
cy.visit('cypress/e2e/type.html')
// find the row that includes the balance text
// and then find a child TD cell with "$"
cy.contains('tr', 'Available balance')
.contains('td', '$') // yields jQuery object
.invoke('text') // yields its text
.invoke('replace', '$', '') // removes "$" character
.then(parseFloat) // yields a number
// confirm the balance is reasonable
.should('be.within', 1, 10_000)
.as('balance')
cy.get('#transfer').type('@balance', { delay: 100 })
cy.get('#transfer').should('have.value', '800')
})
it('types alias inside a longer string', () => {
cy.visit('cypress/e2e/type.html')
cy.wrap('hello').as('greeting')
cy.get('#memo').type('@greeting world!')
cy.get('#memo').should('have.value', 'hello world!')
})