-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds unit tests for the message component
- Loading branch information
Showing
1 changed file
with
51 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,56 @@ | ||
import React from 'react'; | ||
import Message from './index'; | ||
|
||
function Component(props) { | ||
return ( | ||
<Message {...props}> | ||
lorem ipsum | ||
</Message> | ||
); | ||
} | ||
|
||
describe('Message', () => { | ||
it('TODO', () => { | ||
expect(true).to.equal(true); | ||
const infoThemeClass = 'tyk-message--info'; | ||
const successThemeClass = 'tyk-message--success'; | ||
const noMarginClass = 'no-margin'; | ||
const selectors = { | ||
message: '.tyk-message', | ||
closeIcon: '.tyk-icon.tykon-x', | ||
}; | ||
|
||
it('renders the component with the info theme by default', () => { | ||
cy.mount(<Component />) | ||
.get(selectors.message) | ||
.should('exist') | ||
.and('have.class', infoThemeClass); | ||
}); | ||
|
||
it('can be rendered with a different theme', () => { | ||
cy.mount(<Component theme="success" />) | ||
.get(selectors.message) | ||
.should('have.class', successThemeClass); | ||
}); | ||
|
||
it('can be rendered with no margins', () => { | ||
cy.mount(<Component noMargin />) | ||
.get(selectors.message) | ||
.should('have.class', noMarginClass); | ||
}); | ||
|
||
it('can have custom classes', () => { | ||
const myClass = 'foo'; | ||
cy.mount(<Component className={myClass} />) | ||
.get(selectors.message) | ||
.should('have.class', myClass); | ||
}); | ||
|
||
it('renders an icon that calls the onClose callback when clicked', () => { | ||
const onClose = cy.stub(); | ||
cy.mount(<Component onClose={onClose} />) | ||
.get(selectors.closeIcon) | ||
.click() | ||
.then(() => { | ||
expect(onClose).to.be.called; | ||
}); | ||
}); | ||
}); |