Skip to content

Commit 6304a24

Browse files
committed
Add tests for new features
1 parent 4506344 commit 6304a24

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

cypress/integration/test.spec.js

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-env mocha */
2-
/* global cy, expect */
2+
/* global Cypress, cy, expect */
33

44
describe('Integration Tests', () => {
55
before(() => cy.visit('/'))
@@ -105,4 +105,52 @@ describe('Integration Tests', () => {
105105
.get('._toastBtn')
106106
.click()
107107
})
108+
109+
it('Clears all active toasts', () => {
110+
Cypress._.times(3, () => {
111+
cy.get('[data-btn=default]').click()
112+
})
113+
cy.get('._toastItem')
114+
.should($e => {
115+
expect($e).to.have.length(3)
116+
})
117+
cy.window().invoke('toast.pop', 0)
118+
.get('._toastItem')
119+
.should('not.exist')
120+
})
121+
122+
it('push() accepts both string and object', () => {
123+
cy.window().invoke('toast.push', 'Test')
124+
.get('._toastItem')
125+
.contains('Test')
126+
.window().invoke('toast.pop')
127+
.get('._toastItem')
128+
.should('not.exist')
129+
.window().invoke('toast.push', '{"msg":"Test2"}')
130+
.get('._toastItem')
131+
.contains('Test2')
132+
.window().invoke('toast.pop')
133+
})
134+
135+
it('Pushes messages to correct container target', () => {
136+
cy.get('[data-btn=createNewToastContainer]')
137+
.click()
138+
.get('._toastItem')
139+
.should('have.css', 'top', '0px')
140+
.get('._toastBtn')
141+
.click()
142+
})
143+
144+
it('Removes all toasts from selected container target', () => {
145+
Cypress._.times(3, () => {
146+
cy.get('[data-btn=createNewToastContainer]').click()
147+
cy.get('[data-btn=default]').click()
148+
})
149+
cy.get('[data-btn=removeAllToastsFromContainer]')
150+
.click()
151+
.get('._toastItem')
152+
.contains('Hello')
153+
.should('not.contain', 'NEW:')
154+
.window().invoke('toast.pop', 0)
155+
})
108156
})

0 commit comments

Comments
 (0)