|
1 | 1 | /* eslint-env mocha */
|
2 |
| -/* global cy, expect */ |
| 2 | +/* global Cypress, cy, expect */ |
3 | 3 |
|
4 | 4 | describe('Integration Tests', () => {
|
5 | 5 | before(() => cy.visit('/'))
|
@@ -105,4 +105,52 @@ describe('Integration Tests', () => {
|
105 | 105 | .get('._toastBtn')
|
106 | 106 | .click()
|
107 | 107 | })
|
| 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 | + }) |
108 | 156 | })
|
0 commit comments