-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle values null better (#39)
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/// <reference types="cypress" /> | ||
// @ts-check | ||
|
||
import '../../src' | ||
|
||
// https://github.com/bahmutov/cypress-if/issues/38 | ||
describe('null value', () => { | ||
it('handles null assertion', () => { | ||
cy.wrap(null) | ||
.if('null') | ||
.log('null value') | ||
.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('handles not.null assertion', () => { | ||
cy.wrap(null) | ||
.if('not.null') | ||
.log('null value') | ||
.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('handles 42 with not.null assertion', () => { | ||
cy.wrap(42) | ||
.if('not.null') | ||
.log('null value') | ||
.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') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters