-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
319 additions
and
3 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
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,20 @@ | ||
import '@testing-library/jest-dom'; | ||
import { render } from '@testing-library/react'; | ||
import { snapshot } from '../../test'; | ||
import { ProgressBar } from './ProgressBar'; | ||
|
||
describe('ProgressBar', () => { | ||
snapshot(<ProgressBar />, 'default'); | ||
snapshot(<ProgressBar value={50} />, 'value'); | ||
snapshot(<ProgressBar value={50} showValue={false} />, 'hide value'); | ||
snapshot(<ProgressBar value={50} unit="%" />, 'value with unit'); | ||
snapshot(<ProgressBar mode="determinate" value={20} />, 'mode determinate'); | ||
snapshot(<ProgressBar mode="indeterminate" style={{ height: '6px' }} />, 'mode indeterminate'); | ||
test('when mode is invalid throws exception', () => { | ||
try { | ||
const { container } = render(<ProgressBar mode="invalid" value={20} />); | ||
} catch (error) { | ||
expect(error.toString().startsWith("Error: invalid is not a valid mode for the ProgressBar. Valid values are 'determinate' and 'indeterminate'")).toBeTruthy(); | ||
} | ||
}); | ||
}); |
121 changes: 121 additions & 0 deletions
121
components/lib/progressbar/__snapshots__/ProgressBar.spec.js.snap
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,121 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ProgressBar default 1`] = ` | ||
<div> | ||
<div | ||
aria-valuemax="100" | ||
aria-valuemin="0" | ||
class="p-progressbar p-component p-progressbar-determinate" | ||
role="progressbar" | ||
> | ||
<div | ||
class="p-progressbar-value p-progressbar-value-animate" | ||
style="display: flex;" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`ProgressBar hide value 1`] = ` | ||
<div> | ||
<div | ||
aria-valuemax="100" | ||
aria-valuemin="0" | ||
aria-valuenow="50" | ||
class="p-progressbar p-component p-progressbar-determinate" | ||
role="progressbar" | ||
> | ||
<div | ||
class="p-progressbar-value p-progressbar-value-animate" | ||
style="width: 50%; display: flex;" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`ProgressBar mode determinate 1`] = ` | ||
<div> | ||
<div | ||
aria-valuemax="100" | ||
aria-valuemin="0" | ||
aria-valuenow="20" | ||
class="p-progressbar p-component p-progressbar-determinate" | ||
role="progressbar" | ||
> | ||
<div | ||
class="p-progressbar-value p-progressbar-value-animate" | ||
style="width: 20%; display: flex;" | ||
> | ||
<div | ||
class="p-progressbar-label" | ||
> | ||
20% | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`ProgressBar mode indeterminate 1`] = ` | ||
<div> | ||
<div | ||
class="p-progressbar p-component p-progressbar-indeterminate" | ||
role="progressbar" | ||
style="height: 6px;" | ||
> | ||
<div | ||
class="p-progressbar-indeterminate-container" | ||
> | ||
<div | ||
class="p-progressbar-value p-progressbar-value-animate" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`ProgressBar value 1`] = ` | ||
<div> | ||
<div | ||
aria-valuemax="100" | ||
aria-valuemin="0" | ||
aria-valuenow="50" | ||
class="p-progressbar p-component p-progressbar-determinate" | ||
role="progressbar" | ||
> | ||
<div | ||
class="p-progressbar-value p-progressbar-value-animate" | ||
style="width: 50%; display: flex;" | ||
> | ||
<div | ||
class="p-progressbar-label" | ||
> | ||
50% | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`ProgressBar value with unit 1`] = ` | ||
<div> | ||
<div | ||
aria-valuemax="100" | ||
aria-valuemin="0" | ||
aria-valuenow="50" | ||
class="p-progressbar p-component p-progressbar-determinate" | ||
role="progressbar" | ||
> | ||
<div | ||
class="p-progressbar-value p-progressbar-value-animate" | ||
style="width: 50%; display: flex;" | ||
> | ||
<div | ||
class="p-progressbar-label" | ||
> | ||
50% | ||
</div> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import '@testing-library/jest-dom'; | ||
import { ProgressSpinner } from './ProgressSpinner'; | ||
|
||
import { snapshot } from '../../test'; | ||
|
||
describe('ProgressSpinner', () => { | ||
snapshot(<ProgressSpinner />, 'default'); | ||
snapshot(<ProgressSpinner strokeWidth="3" />, 'strokeWidth'); | ||
snapshot(<ProgressSpinner fill="green" />, 'fill'); | ||
snapshot(<ProgressSpinner animationDuration="5s" />, 'animationDuration'); | ||
}); |
105 changes: 105 additions & 0 deletions
105
components/lib/progressspinner/__snapshots__/ProgressSpinner.spec.js.snap
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,105 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ProgressSpinner animationDuration 1`] = ` | ||
<div> | ||
<div | ||
aria-busy="true" | ||
class="p-progress-spinner" | ||
role="alert" | ||
> | ||
<svg | ||
class="p-progress-spinner-svg" | ||
style="animation-duration: 5s;" | ||
viewBox="25 25 50 50" | ||
> | ||
<circle | ||
class="p-progress-spinner-circle" | ||
cx="50" | ||
cy="50" | ||
fill="none" | ||
r="20" | ||
stroke-miterlimit="10" | ||
stroke-width="2" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`ProgressSpinner default 1`] = ` | ||
<div> | ||
<div | ||
aria-busy="true" | ||
class="p-progress-spinner" | ||
role="alert" | ||
> | ||
<svg | ||
class="p-progress-spinner-svg" | ||
style="animation-duration: 2s;" | ||
viewBox="25 25 50 50" | ||
> | ||
<circle | ||
class="p-progress-spinner-circle" | ||
cx="50" | ||
cy="50" | ||
fill="none" | ||
r="20" | ||
stroke-miterlimit="10" | ||
stroke-width="2" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`ProgressSpinner fill 1`] = ` | ||
<div> | ||
<div | ||
aria-busy="true" | ||
class="p-progress-spinner" | ||
role="alert" | ||
> | ||
<svg | ||
class="p-progress-spinner-svg" | ||
style="animation-duration: 2s;" | ||
viewBox="25 25 50 50" | ||
> | ||
<circle | ||
class="p-progress-spinner-circle" | ||
cx="50" | ||
cy="50" | ||
fill="green" | ||
r="20" | ||
stroke-miterlimit="10" | ||
stroke-width="2" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`ProgressSpinner strokeWidth 1`] = ` | ||
<div> | ||
<div | ||
aria-busy="true" | ||
class="p-progress-spinner" | ||
role="alert" | ||
> | ||
<svg | ||
class="p-progress-spinner-svg" | ||
style="animation-duration: 2s;" | ||
viewBox="25 25 50 50" | ||
> | ||
<circle | ||
class="p-progress-spinner-circle" | ||
cx="50" | ||
cy="50" | ||
fill="none" | ||
r="20" | ||
stroke-miterlimit="10" | ||
stroke-width="3" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
`; |