-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TextInput: add optional labelColor property to control label color (#463
- Loading branch information
1 parent
6f8207f
commit 0ef6239
Showing
4 changed files
with
85 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
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,60 @@ | ||
import { TextField } from "@/components/Input/TextField"; | ||
import { renderCUI } from "@/utils/test-utils"; | ||
import { useState } from "react"; | ||
|
||
const TextFieldWrapper = ({ | ||
initialText = "", | ||
label, | ||
labelColor, | ||
}: { | ||
initialText?: string; | ||
label: string; | ||
labelColor?: string; | ||
}) => { | ||
const [text, setText] = useState<string>(initialText); | ||
|
||
console.log(text); | ||
return ( | ||
<TextField | ||
label={label} | ||
labelColor={labelColor} | ||
onChange={setText} | ||
value={text} | ||
/> | ||
); | ||
}; | ||
|
||
describe("TextField", () => { | ||
describe("label color", () => { | ||
it("is the default color when labelColor is not set", () => { | ||
const label = "Hello there!"; | ||
const text = "General Kenobi"; | ||
|
||
const { getByText } = renderCUI( | ||
<TextFieldWrapper | ||
label={label} | ||
initialText={text} | ||
/> | ||
); | ||
|
||
const labelElement = getByText(label); | ||
expect(labelElement).toBeInTheDocument(); | ||
expect(labelElement).toHaveStyle("color: rgb(179, 182, 189)"); | ||
}); | ||
|
||
it("is the color of the passed in labelColor", () => { | ||
const label = "Hello there!"; | ||
|
||
const { getByText } = renderCUI( | ||
<TextFieldWrapper | ||
label={label} | ||
labelColor="#FF0000" | ||
/> | ||
); | ||
|
||
const labelElement = getByText(label); | ||
expect(labelElement).toBeInTheDocument(); | ||
expect(labelElement).toHaveStyle("color: #FF0000"); | ||
}); | ||
}); | ||
}); |
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