-
Notifications
You must be signed in to change notification settings - Fork 844
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* toast jest tests * using test style guide this time * test each color value
- Loading branch information
Showing
5 changed files
with
162 additions
and
7 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
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,17 +1,116 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EuiToast Props color danger is rendered 1`] = ` | ||
<div | ||
className="euiToast euiToast--danger" | ||
> | ||
<div | ||
className="euiToastHeader" | ||
> | ||
<span | ||
className="euiToastHeader__title" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`EuiToast Props color primary is rendered 1`] = ` | ||
<div | ||
className="euiToast euiToast--primary" | ||
> | ||
<div | ||
className="euiToastHeader" | ||
> | ||
<span | ||
className="euiToastHeader__title" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`EuiToast Props color success is rendered 1`] = ` | ||
<div | ||
className="euiToast euiToast--success" | ||
> | ||
<div | ||
className="euiToastHeader" | ||
> | ||
<span | ||
className="euiToastHeader__title" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`EuiToast Props color warning is rendered 1`] = ` | ||
<div | ||
className="euiToast euiToast--warning" | ||
> | ||
<div | ||
className="euiToastHeader" | ||
> | ||
<span | ||
className="euiToastHeader__title" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`EuiToast Props iconType is rendered 1`] = ` | ||
<div | ||
className="euiToast" | ||
> | ||
<div | ||
className="euiToastHeader" | ||
> | ||
<EuiIcon | ||
aria-hidden="true" | ||
className="euiToastHeader__icon" | ||
size="m" | ||
type="user" | ||
/> | ||
<span | ||
className="euiToastHeader__title" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`EuiToast Props title is rendered 1`] = ` | ||
<div | ||
className="euiToast" | ||
> | ||
<div | ||
className="euiToastHeader" | ||
> | ||
<span | ||
className="euiToastHeader__title" | ||
> | ||
toast title | ||
</span> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`EuiToast is rendered 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="euiToast testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
<div | ||
class="euiToastHeader" | ||
class="euiToastHeader euiToastHeader--withBody" | ||
> | ||
<span | ||
class="euiToastHeader__title" | ||
/> | ||
</div> | ||
<div | ||
class="euiText euiText--small" | ||
> | ||
<p> | ||
Hi | ||
</p> | ||
</div> | ||
</div> | ||
`; |
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
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,16 +1,64 @@ | ||
import React from 'react'; | ||
import { render } from 'enzyme'; | ||
import { requiredProps } from '../../test/required_props'; | ||
import { render, shallow } from 'enzyme'; | ||
import sinon from 'sinon'; | ||
import { | ||
findTestSubject, | ||
requiredProps | ||
} from '../../test'; | ||
|
||
import { EuiToast } from './toast'; | ||
import { | ||
COLORS, | ||
EuiToast | ||
} from './toast'; | ||
|
||
describe('EuiToast', () => { | ||
test('is rendered', () => { | ||
const component = render( | ||
<EuiToast {...requiredProps} /> | ||
<EuiToast {...requiredProps}> | ||
<p>Hi</p> | ||
</EuiToast> | ||
); | ||
|
||
expect(component) | ||
.toMatchSnapshot(); | ||
}); | ||
|
||
describe('Props', () => { | ||
describe('title', () => { | ||
test('is rendered', () => { | ||
const component = <EuiToast title="toast title" />; | ||
expect(shallow(component)).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('color', () => { | ||
COLORS.forEach(color => { | ||
test(`${color} is rendered`, () => { | ||
const component = <EuiToast color={color} />; | ||
expect(shallow(component)).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('iconType', () => { | ||
test('is rendered', () => { | ||
const component = <EuiToast iconType="user" />; | ||
expect(shallow(component)).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('onClose', () => { | ||
test('is called when the close button is clicked', () => { | ||
const onCloseHandler = sinon.stub(); | ||
|
||
const component = shallow( | ||
<EuiToast onClose={onCloseHandler} /> | ||
); | ||
const closeButton = findTestSubject(component, 'toastCloseButton'); | ||
closeButton.simulate('click'); | ||
|
||
sinon.assert.calledOnce(onCloseHandler); | ||
}); | ||
}); | ||
}); | ||
}); |