diff --git a/src/modules/option/components/RadioButton/RadioButton.test.tsx b/src/modules/option/components/RadioButton/RadioButton.test.tsx
index 6e4b1ab..c8f2cce 100644
--- a/src/modules/option/components/RadioButton/RadioButton.test.tsx
+++ b/src/modules/option/components/RadioButton/RadioButton.test.tsx
@@ -4,6 +4,7 @@ import {
screen
} from '@testing-library/react';
import '@testing-library/jest-dom';
+import userEvent from '@testing-library/user-event';
import * as ButtonBase from '@tesseract-design/web-base-button';
import * as CheckControlBase from '@tesseract-design/web-base-checkcontrol';
import { RadioButton } from '.';
@@ -19,4 +20,151 @@ describe('RadioButton', () => {
const checkbox = screen.getByRole('radio');
expect(checkbox).toBeInTheDocument();
});
+
+ it('should render a subtext', () => {
+ render(
+
+ );
+ const subtext: HTMLElement = screen.getByTestId('subtext');
+ expect(subtext).toBeInTheDocument();
+ });
+
+ it('should render a badge', () => {
+ render(
+
+ );
+ const badge: HTMLElement = screen.getByTestId('badge');
+ expect(badge).toBeInTheDocument();
+ });
+
+ it('should handle click events', () => {
+ const onClick = jest.fn();
+ render(
+
+ );
+ const button: HTMLInputElement = screen.getByRole('radio');
+ userEvent.click(button);
+ expect(onClick).toBeCalled();
+ });
+
+ it('should render a compact button', () => {
+ render(
+
+ );
+
+ expect(ButtonBase.Button).toBeCalledWith(expect.objectContaining({
+ compact: true,
+ }));
+
+ expect(ButtonBase.Label).toBeCalledWith(expect.objectContaining({
+ compact: true,
+ }));
+ });
+
+ describe.each([
+ ButtonBase.ButtonSize.SMALL,
+ ButtonBase.ButtonSize.MEDIUM,
+ ButtonBase.ButtonSize.LARGE,
+ ])('on %s size', (size) => {
+ it('should render button styles', () => {
+ render(
+
+ );
+
+ expect(ButtonBase.Button).toBeCalledWith(expect.objectContaining({
+ size,
+ }));
+ });
+
+ it('should render badge styles', () => {
+ render(
+
+ );
+
+ expect(ButtonBase.BadgeContainer).toBeCalledWith(expect.objectContaining({
+ size,
+ }));
+ });
+ });
+
+ it.each([
+ ButtonBase.ButtonVariant.OUTLINE,
+ ButtonBase.ButtonVariant.FILLED,
+ ])('should render a button with variant %s', (variant) => {
+ render(
+
+ );
+
+ expect(ButtonBase.Button).toBeCalledWith(expect.objectContaining({
+ variant,
+ }));
+ });
+
+ it('should render a bordered button', () => {
+ render(
+
+ );
+
+ expect(ButtonBase.Border).toBeCalledWith(expect.objectContaining({
+ border: true,
+ }));
+ });
+
+ it('should render a block button', () => {
+ render(
+
+ );
+
+ expect(ButtonBase.Button).toBeCalledWith(expect.objectContaining({
+ block: true,
+ }));
+
+ expect(ButtonBase.Border).toBeCalledWith(expect.objectContaining({
+ block: true,
+ }));
+
+ expect(CheckControlBase.ClickAreaWrapper).toBeCalledWith(expect.objectContaining({
+ block: true,
+ }));
+ });
+
+ it('should render children', () => {
+ render(
+
+ Foo
+
+ );
+
+ const children: HTMLElement = screen.getByTestId('children');
+ expect(children).toHaveTextContent('Foo');
+ });
+
+ it('should render a disabled button', () => {
+ render(
+
+ );
+ const button: HTMLButtonElement = screen.getByRole('radio');
+ expect(button).toBeDisabled();
+ });
});
diff --git a/src/modules/option/components/RadioButton/index.tsx b/src/modules/option/components/RadioButton/index.tsx
index 5cf4bc0..534d11d 100644
--- a/src/modules/option/components/RadioButton/index.tsx
+++ b/src/modules/option/components/RadioButton/index.tsx
@@ -100,6 +100,7 @@ export const RadioButton = React.forwardRef(
>
(
{' '}
(
{' '}
{badge}
diff --git a/src/modules/option/components/RadioTickBox/RadioTickBox.test.tsx b/src/modules/option/components/RadioTickBox/RadioTickBox.test.tsx
index 6469ea1..7edea85 100644
--- a/src/modules/option/components/RadioTickBox/RadioTickBox.test.tsx
+++ b/src/modules/option/components/RadioTickBox/RadioTickBox.test.tsx
@@ -4,6 +4,7 @@ import {
screen
} from '@testing-library/react';
import '@testing-library/jest-dom';
+import userEvent from '@testing-library/user-event';
import * as CheckControlBase from '@tesseract-design/web-base-checkcontrol';
import { RadioTickBox } from '.';
@@ -17,4 +18,50 @@ describe('RadioTickBox', () => {
const checkbox = screen.getByRole('radio');
expect(checkbox).toBeInTheDocument();
});
+
+ it('should render a compact tick box', () => {
+ render(
+
+ );
+
+ expect(CheckControlBase.CheckIndicatorArea).toBeCalledWith(expect.objectContaining({
+ compact: true,
+ }));
+ });
+
+ it('should render a block tick box', () => {
+ render(
+
+ );
+
+ expect(CheckControlBase.ClickAreaWrapper).toBeCalledWith(expect.objectContaining({
+ block: true,
+ }));
+ });
+
+ it('should render a subtext', () => {
+ render(
+
+ );
+ const subtext: HTMLElement = screen.getByTestId('subtext');
+ expect(subtext).toBeInTheDocument();
+ });
+
+ it('should handle click events', () => {
+ const onClick = jest.fn();
+ render(
+
+ );
+ const button: HTMLInputElement = screen.getByRole('radio');
+ userEvent.click(button);
+ expect(onClick).toBeCalled();
+ });
});
diff --git a/src/modules/option/components/RadioTickBox/index.tsx b/src/modules/option/components/RadioTickBox/index.tsx
index fd4d677..483a0bf 100644
--- a/src/modules/option/components/RadioTickBox/index.tsx
+++ b/src/modules/option/components/RadioTickBox/index.tsx
@@ -72,6 +72,7 @@ export const RadioTickBox = React.forwardRef
{subtext}
diff --git a/src/modules/option/components/ToggleButton/ToggleButton.test.tsx b/src/modules/option/components/ToggleButton/ToggleButton.test.tsx
index 766daae..19511b4 100644
--- a/src/modules/option/components/ToggleButton/ToggleButton.test.tsx
+++ b/src/modules/option/components/ToggleButton/ToggleButton.test.tsx
@@ -4,6 +4,7 @@ import {
screen
} from '@testing-library/react';
import '@testing-library/jest-dom';
+import userEvent from '@testing-library/user-event';
import * as ButtonBase from '@tesseract-design/web-base-button';
import * as CheckControlBase from '@tesseract-design/web-base-checkcontrol';
import { ToggleButton } from '.';
@@ -29,4 +30,175 @@ describe('ToggleButton', () => {
const checkbox = screen.getByRole('checkbox');
expect(checkbox).toHaveProperty('indeterminate', true);
});
+
+ it('should render a subtext', () => {
+ render(
+
+ );
+ const subtext: HTMLElement = screen.getByTestId('subtext');
+ expect(subtext).toBeInTheDocument();
+ });
+
+ it('should render a badge', () => {
+ render(
+
+ );
+ const badge: HTMLElement = screen.getByTestId('badge');
+ expect(badge).toBeInTheDocument();
+ });
+
+ describe('on indeterminate', () => {
+ it('should render an indeterminate checkbox', () => {
+ render(
+
+ );
+ const checkbox = screen.getByRole('checkbox');
+ expect(checkbox).toHaveProperty('indeterminate', true);
+ });
+
+ it('should acknowledge passed ref', () => {
+ const ref = React.createRef()
+ render(
+
+ );
+ expect(ref.current).toHaveProperty('indeterminate', true);
+ });
+ });
+
+
+ it('should handle click events', () => {
+ const onClick = jest.fn();
+ render(
+
+ );
+ const button: HTMLInputElement = screen.getByRole('checkbox');
+ userEvent.click(button);
+ expect(onClick).toBeCalled();
+ });
+
+ it('should render a compact button', () => {
+ render(
+
+ );
+
+ expect(ButtonBase.Button).toBeCalledWith(expect.objectContaining({
+ compact: true,
+ }));
+
+ expect(ButtonBase.Label).toBeCalledWith(expect.objectContaining({
+ compact: true,
+ }));
+ });
+
+ describe.each([
+ ButtonBase.ButtonSize.SMALL,
+ ButtonBase.ButtonSize.MEDIUM,
+ ButtonBase.ButtonSize.LARGE,
+ ])('on %s size', (size) => {
+ it('should render button styles', () => {
+ render(
+
+ );
+
+ expect(ButtonBase.Button).toBeCalledWith(expect.objectContaining({
+ size,
+ }));
+ });
+
+ it('should render badge styles', () => {
+ render(
+
+ );
+
+ expect(ButtonBase.BadgeContainer).toBeCalledWith(expect.objectContaining({
+ size,
+ }));
+ });
+ });
+
+ it.each([
+ ButtonBase.ButtonVariant.OUTLINE,
+ ButtonBase.ButtonVariant.FILLED,
+ ])('should render a button with variant %s', (variant) => {
+ render(
+
+ );
+
+ expect(ButtonBase.Button).toBeCalledWith(expect.objectContaining({
+ variant,
+ }));
+ });
+
+ it('should render a bordered button', () => {
+ render(
+
+ );
+
+ expect(ButtonBase.Border).toBeCalledWith(expect.objectContaining({
+ border: true,
+ }));
+ });
+
+ it('should render a block button', () => {
+ render(
+
+ );
+
+ expect(ButtonBase.Button).toBeCalledWith(expect.objectContaining({
+ block: true,
+ }));
+
+ expect(ButtonBase.Border).toBeCalledWith(expect.objectContaining({
+ block: true,
+ }));
+
+ expect(CheckControlBase.ClickAreaWrapper).toBeCalledWith(expect.objectContaining({
+ block: true,
+ }));
+ });
+
+ it('should render children', () => {
+ render(
+
+ Foo
+
+ );
+
+ const children: HTMLElement = screen.getByTestId('children');
+ expect(children).toHaveTextContent('Foo');
+ });
+
+ it('should render a disabled button', () => {
+ render(
+
+ );
+ const button: HTMLButtonElement = screen.getByRole('checkbox');
+ expect(button).toBeDisabled();
+ });
});
diff --git a/src/modules/option/components/ToggleButton/index.tsx b/src/modules/option/components/ToggleButton/index.tsx
index 269627c..eac93e5 100644
--- a/src/modules/option/components/ToggleButton/index.tsx
+++ b/src/modules/option/components/ToggleButton/index.tsx
@@ -133,6 +133,7 @@ export const ToggleButton = React.forwardRef
{badge}
diff --git a/src/modules/option/components/ToggleSwitch/ToggleSwitch.test.tsx b/src/modules/option/components/ToggleSwitch/ToggleSwitch.test.tsx
index acc4ac8..9b93f3d 100644
--- a/src/modules/option/components/ToggleSwitch/ToggleSwitch.test.tsx
+++ b/src/modules/option/components/ToggleSwitch/ToggleSwitch.test.tsx
@@ -4,6 +4,7 @@ import {
screen
} from '@testing-library/react';
import '@testing-library/jest-dom';
+import userEvent from '@testing-library/user-event';
import * as CheckControlBase from '@tesseract-design/web-base-checkcontrol';
import { ToggleSwitch } from '.';
@@ -17,4 +18,50 @@ describe('ToggleSwitch', () => {
const checkbox = screen.getByRole('checkbox');
expect(checkbox).toBeInTheDocument();
});
+
+ it('should render a compact switch', () => {
+ render(
+
+ );
+
+ expect(CheckControlBase.CheckIndicatorArea).toBeCalledWith(expect.objectContaining({
+ compact: true,
+ }));
+ });
+
+ it('should render a block switch', () => {
+ render(
+
+ );
+
+ expect(CheckControlBase.ClickAreaWrapper).toBeCalledWith(expect.objectContaining({
+ block: true,
+ }));
+ });
+
+ it('should render a subtext', () => {
+ render(
+
+ );
+ const subtext: HTMLElement = screen.getByTestId('subtext');
+ expect(subtext).toBeInTheDocument();
+ });
+
+ it('should handle click events', () => {
+ const onClick = jest.fn();
+ render(
+
+ );
+ const button: HTMLInputElement = screen.getByRole('checkbox');
+ userEvent.click(button);
+ expect(onClick).toBeCalled();
+ });
});
diff --git a/src/modules/option/components/ToggleSwitch/index.tsx b/src/modules/option/components/ToggleSwitch/index.tsx
index 5d43131..edc5264 100644
--- a/src/modules/option/components/ToggleSwitch/index.tsx
+++ b/src/modules/option/components/ToggleSwitch/index.tsx
@@ -92,6 +92,7 @@ export const ToggleSwitch = React.forwardRef
{subtext}
diff --git a/src/modules/option/components/ToggleTickBox/ToggleTickBox.test.tsx b/src/modules/option/components/ToggleTickBox/ToggleTickBox.test.tsx
index 9bc506d..b443323 100644
--- a/src/modules/option/components/ToggleTickBox/ToggleTickBox.test.tsx
+++ b/src/modules/option/components/ToggleTickBox/ToggleTickBox.test.tsx
@@ -4,6 +4,7 @@ import {
screen
} from '@testing-library/react';
import '@testing-library/jest-dom';
+import userEvent from '@testing-library/user-event';
import * as CheckControlBase from '@tesseract-design/web-base-checkcontrol';
import { ToggleTickBox } from '.';
@@ -18,13 +19,72 @@ describe('ToggleTickBox', () => {
expect(checkbox).toBeInTheDocument();
});
- it('should render an indeterminate checkbox', () => {
+ describe('on indeterminate', () => {
+ it('should render an indeterminate checkbox', () => {
+ render(
+
+ );
+ const checkbox = screen.getByRole('checkbox');
+ expect(checkbox).toHaveProperty('indeterminate', true);
+ });
+
+ it('should acknowledge passed ref', () => {
+ const ref = React.createRef()
+ render(
+
+ );
+ expect(ref.current).toHaveProperty('indeterminate', true);
+ });
+ });
+
+ it('should render a compact tick box', () => {
render(
);
- const checkbox = screen.getByRole('checkbox');
- expect(checkbox).toHaveProperty('indeterminate', true);
+
+ expect(CheckControlBase.CheckIndicatorArea).toBeCalledWith(expect.objectContaining({
+ compact: true,
+ }));
+ });
+
+ it('should render a block tick box', () => {
+ render(
+
+ );
+
+ expect(CheckControlBase.ClickAreaWrapper).toBeCalledWith(expect.objectContaining({
+ block: true,
+ }));
+ });
+
+ it('should render a subtext', () => {
+ render(
+
+ );
+ const subtext: HTMLElement = screen.getByTestId('subtext');
+ expect(subtext).toBeInTheDocument();
+ });
+
+ it('should handle click events', () => {
+ const onClick = jest.fn();
+ render(
+
+ );
+ const button: HTMLInputElement = screen.getByRole('checkbox');
+ userEvent.click(button);
+ expect(onClick).toBeCalled();
});
});
diff --git a/src/modules/option/components/ToggleTickBox/index.tsx b/src/modules/option/components/ToggleTickBox/index.tsx
index 37110e2..a799dc1 100644
--- a/src/modules/option/components/ToggleTickBox/index.tsx
+++ b/src/modules/option/components/ToggleTickBox/index.tsx
@@ -105,6 +105,7 @@ export const ToggleTickBox = React.forwardRef
{subtext}
diff --git a/src/pages/categories/option/index.tsx b/src/pages/categories/option/index.tsx
index ce40b63..7e369e4 100644
--- a/src/pages/categories/option/index.tsx
+++ b/src/pages/categories/option/index.tsx
@@ -309,30 +309,13 @@ const OptionPage: NextPage = ({
-
-
- Switch
-
@@ -344,7 +327,6 @@ const OptionPage: NextPage = ({
Button
@@ -354,7 +336,6 @@ const OptionPage: NextPage = ({
Button
@@ -364,7 +345,6 @@ const OptionPage: NextPage = ({
Button
@@ -375,7 +355,6 @@ const OptionPage: NextPage = ({
border
variant={ButtonVariant.FILLED}
block
- appearance={CheckControlAppearance.BUTTON}
name="RadioButton"
>
Button
@@ -385,7 +364,6 @@ const OptionPage: NextPage = ({
Button
@@ -396,7 +374,6 @@ const OptionPage: NextPage = ({
variant={ButtonVariant.FILLED}
block
disabled
- appearance={CheckControlAppearance.BUTTON}
name="RadioButton"
>
Button
@@ -407,7 +384,6 @@ const OptionPage: NextPage = ({
border
block
disabled
- appearance={CheckControlAppearance.BUTTON}
name="RadioButton"
>
Button
@@ -419,7 +395,6 @@ const OptionPage: NextPage = ({
variant={ButtonVariant.FILLED}
block
disabled
- appearance={CheckControlAppearance.BUTTON}
name="RadioButton"
>
Button
@@ -437,7 +412,6 @@ const OptionPage: NextPage = ({
block
border
size={ButtonSize.SMALL}
- appearance={CheckControlAppearance.BUTTON}
name="RadioButton"
>
Button
@@ -449,7 +423,6 @@ const OptionPage: NextPage = ({
border
variant={ButtonVariant.FILLED}
size={ButtonSize.SMALL}
- appearance={CheckControlAppearance.BUTTON}
name="RadioButton"
>
Button
@@ -460,7 +433,6 @@ const OptionPage: NextPage = ({
block
border
size={ButtonSize.MEDIUM}
- appearance={CheckControlAppearance.BUTTON}
name="RadioButton"
>
Button
@@ -472,7 +444,6 @@ const OptionPage: NextPage = ({
border
variant={ButtonVariant.FILLED}
size={ButtonSize.MEDIUM}
- appearance={CheckControlAppearance.BUTTON}
name="RadioButton"
>
Button
@@ -483,7 +454,6 @@ const OptionPage: NextPage = ({
block
border
size={ButtonSize.LARGE}
- appearance={CheckControlAppearance.BUTTON}
name="RadioButton"
>
Button