Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quantum-kittens
GitHub Repository: quantum-kittens/platypus
Path: blob/main/cypress/integration/binary-demo.spec.js
3855 views
1
/// <reference types="cypress" />
2
3
describe('Binary demo', () => {
4
it('Should render on page', () => {
5
const binaryDemo = '.binary-demo'
6
7
cy.visit('/course/introduction/the-atoms-of-computation')
8
cy.url().should('include', 'introduction/the-atoms-of-computation')
9
10
cy.get(binaryDemo).scrollIntoView().should('be.visible')
11
})
12
13
it('Should render all Binary demo tiles', () => {
14
const binaryDemoTiles = '.binary-tile'
15
const expectedTileCount = 6
16
17
cy.get(binaryDemoTiles).should('have.length', expectedTileCount)
18
})
19
20
it('Should render Decimal total', () => {
21
const decimalTotal = '[data-test="binary-demo-total"] .binary-demo__block'
22
const expectedDecimalTotal = 25
23
24
cy.get(decimalTotal).should('be.visible')
25
cy.get(decimalTotal).should('have.text', expectedDecimalTotal)
26
})
27
28
it('Should update Decimal total', () => {
29
const binaryDemo = '.binary'
30
const binaryDemoBtns = '.binary-tile'
31
const decimalTotal = '[data-test="binary-demo-total"] .binary-demo__block'
32
const initialTotal = 25
33
const updatedTotalEl = '[data-test="binary-demo-total"] .binary-demo__block'
34
const expectedUpdatedTotal = 57
35
36
cy.visit('/course/introduction/the-atoms-of-computation')
37
cy.url().should('include', 'introduction/the-atoms-of-computation')
38
39
cy.get(binaryDemo).scrollIntoView()
40
cy.get(decimalTotal).should('have.text', initialTotal)
41
cy.get(binaryDemoBtns).first().click() // add 32
42
cy.get(updatedTotalEl).should('have.text', expectedUpdatedTotal)
43
cy.get(binaryDemoBtns).first().click() // remove 32
44
cy.get(updatedTotalEl).should('have.text', initialTotal)
45
})
46
})
47
48