Skip to content

Commit

Permalink
updated prop Button props type and added .ts files to jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
recondesigns committed Feb 29, 2024
1 parent 747cfda commit 05a689c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
30 changes: 5 additions & 25 deletions components/Buttons/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type GoogleAnalyticsEventPropType = {
*/
category: string;
/**
* More precise labelling of the related action. E.g. alongside the 'Added a component' action,
* More precise labeling of the related action. E.g. alongside the 'Added a component' action,
* we could add the name of a component as the label. E.g. 'Survey', 'Heading', 'Button', etc.
*/
label?: string;
Expand Down Expand Up @@ -45,14 +45,6 @@ type ButtonProps = {
* Element used as the button label.
*/
children: React.ReactNode | string;
/**
* Applies classnames to the base element.
*/
className?: string;
/**
* Disables user interaction with the component.
*/
disabled?: boolean;
/**
* Forces the component's width as wide as its parent container's width.
*/
Expand All @@ -61,19 +53,10 @@ type ButtonProps = {
* Function to be called when button is clicked.
*/
onClick?: () => void | undefined;
/**
* Sets the tab index order of the base element.
*/
tabIndex?: string | number;
/**
* Sets the button color theme.
*/
theme?: 'primary' | 'secondary';
/**
* Applies a button type to the base element.
*/
type?: 'button' | 'reset' | 'submit';
datum?: any;
} & React.ButtonHTMLAttributes<HTMLButtonElement>;

export default function Button({
Expand All @@ -89,7 +72,6 @@ export default function Button({
tabIndex = 0,
theme = 'primary',
type = 'button',
datum = '',
...rest
}: ButtonProps) {
const customDataAttributes = getDataAttributes(rest);
Expand All @@ -100,11 +82,6 @@ export default function Button({
label: typeof children === 'string' ? children : undefined,
};

const clickHandler = () => {
gtag.event(eventConfig);
onClick();
};

return (
<button
className={classNames(styles.Button, className, styles[theme], {
Expand All @@ -113,7 +90,10 @@ export default function Button({
})}
data-testid={BUTTON}
disabled={disabled}
onClick={clickHandler}
onClick={() => {
gtag.event(eventConfig);
onClick();
}}
tabIndex={tabIndex}
type={type}
{...customDataAttributes}
Expand Down
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ module.exports = {
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
testMatch: ['<rootDir>/**/*.test.js', '<rootDir>/**/*.test.tsx'],
testMatch: [
'<rootDir>/**/*.test.js',
'<rootDir>/**/*.test.jsx',
'<rootDir>/**/*.test.ts',
'<rootDir>/**/*.test.tsx',
],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
Expand Down

0 comments on commit 05a689c

Please sign in to comment.