Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix(form): Fixed floating state for controlled text fields
chore(form): refactored TextField to use new useFieldStates hook chore(form): Updated NativeSelect to use new useFieldStates hook chore(form): Moved useFieldStates to parent folder and added documentation chore(form): Increased test coverage Closes #1043
- Loading branch information
Showing
13 changed files
with
516 additions
and
134 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from "react"; | ||
import { render } from "@testing-library/react"; | ||
|
||
import { FormThemeOptions, FormThemeProvider } from "../FormThemeProvider"; | ||
import { TextField } from "../text-field/TextField"; | ||
|
||
describe("FormThemeProvider", () => { | ||
it("should default to the outline theme and left direction", () => { | ||
function Test(props: FormThemeOptions) { | ||
return ( | ||
<FormThemeProvider {...props}> | ||
<TextField id="field" label="Label" /> | ||
</FormThemeProvider> | ||
); | ||
} | ||
|
||
const { container, rerender } = render(<Test />); | ||
expect(container).toMatchSnapshot(); | ||
|
||
rerender(<Test theme="underline" underlineDirection="center" />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
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,41 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`FormThemeProvider should default to the outline theme and left direction 1`] = ` | ||
<div> | ||
<div | ||
class="rmd-text-field-container rmd-text-field-container--outline rmd-text-field-container--hoverable rmd-text-field-container--label" | ||
> | ||
<label | ||
class="rmd-label rmd-floating-label" | ||
for="field" | ||
> | ||
Label | ||
</label> | ||
<input | ||
class="rmd-text-field rmd-text-field--floating" | ||
id="field" | ||
type="text" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`FormThemeProvider should default to the outline theme and left direction 2`] = ` | ||
<div> | ||
<div | ||
class="rmd-text-field-container rmd-text-field-container--hoverable rmd-text-field-container--label rmd-text-field-container--underline rmd-text-field-container--underline-labelled rmd-text-field-container--underline-center" | ||
> | ||
<label | ||
class="rmd-label rmd-floating-label" | ||
for="field" | ||
> | ||
Label | ||
</label> | ||
<input | ||
class="rmd-text-field rmd-text-field--floating" | ||
id="field" | ||
type="text" | ||
/> | ||
</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
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.