-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.4.4: Fixed bug when inputing a value smaller than 0 in a field
- Loading branch information
1 parent
f777d91
commit 10b8d9e
Showing
14 changed files
with
361 additions
and
226 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`durationField can match snapshot 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth" | ||
> | ||
<label | ||
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiFormLabel-filled" | ||
data-shrink="true" | ||
> | ||
Minutes | ||
</label> | ||
<div | ||
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl" | ||
> | ||
<input | ||
aria-invalid="false" | ||
class="MuiInputBase-input MuiInput-input" | ||
type="number" | ||
value="30" | ||
/> | ||
</div> | ||
</div> | ||
</DocumentFragment> | ||
`; | ||
|
||
exports[`durationField can match snapshot with custom labels 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth" | ||
> | ||
<label | ||
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiFormLabel-filled" | ||
data-shrink="true" | ||
> | ||
CUSTOM_LABEL | ||
</label> | ||
<div | ||
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl" | ||
> | ||
<input | ||
aria-invalid="false" | ||
class="MuiInputBase-input MuiInput-input" | ||
type="number" | ||
value="30" | ||
/> | ||
</div> | ||
</div> | ||
</DocumentFragment> | ||
`; |
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,64 @@ | ||
import {fireEvent, render, screen, waitFor} from "@testing-library/react"; | ||
import * as React from "react"; | ||
import {DurationField} from "../durationField"; | ||
|
||
describe('durationField', ()=>{ | ||
|
||
it('can match snapshot', async () => { | ||
await waitFor(() => { | ||
expect( | ||
render( | ||
<DurationField | ||
view={"minutes"} | ||
duration={{minutes: 30}} | ||
onConfirm={() => { | ||
}} | ||
/> | ||
).asFragment() | ||
).toMatchSnapshot(); | ||
}); | ||
}) | ||
|
||
it('can match snapshot with custom labels', async () => { | ||
await waitFor(() => { | ||
expect( | ||
render( | ||
<DurationField | ||
labels={{ | ||
minutes: 'CUSTOM_LABEL' | ||
}} | ||
view={"minutes"} | ||
duration={{minutes: 30}} | ||
onConfirm={() => { | ||
}} | ||
/> | ||
).asFragment() | ||
).toMatchSnapshot(); | ||
}); | ||
}) | ||
|
||
|
||
it('can confirm value when value is invalid', async () => { | ||
|
||
const mockOnConfirm = jest.fn() | ||
|
||
const utils = render( | ||
<DurationField | ||
view={"minutes"} | ||
duration={{minutes: 30}} | ||
onConfirm={mockOnConfirm} | ||
inputProps={{ | ||
title: 'fieldTitle' | ||
}} | ||
/> | ||
) | ||
|
||
const field: any= utils.getByTitle('fieldTitle') | ||
|
||
expect(field.value).toBe('30') | ||
fireEvent.change(field, {target: {value: NaN}}) | ||
fireEvent.blur(field) | ||
expect(field.value).toBe('') | ||
expect(mockOnConfirm).toHaveBeenCalledWith(undefined) | ||
}) | ||
}) |
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
Oops, something went wrong.