Skip to content

Commit 05a689c

Browse files
committed
updated prop Button props type and added .ts files to jest config
1 parent 747cfda commit 05a689c

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

components/Buttons/Button/Button.tsx

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type GoogleAnalyticsEventPropType = {
1616
*/
1717
category: string;
1818
/**
19-
* More precise labelling of the related action. E.g. alongside the 'Added a component' action,
19+
* More precise labeling of the related action. E.g. alongside the 'Added a component' action,
2020
* we could add the name of a component as the label. E.g. 'Survey', 'Heading', 'Button', etc.
2121
*/
2222
label?: string;
@@ -45,14 +45,6 @@ type ButtonProps = {
4545
* Element used as the button label.
4646
*/
4747
children: React.ReactNode | string;
48-
/**
49-
* Applies classnames to the base element.
50-
*/
51-
className?: string;
52-
/**
53-
* Disables user interaction with the component.
54-
*/
55-
disabled?: boolean;
5648
/**
5749
* Forces the component's width as wide as its parent container's width.
5850
*/
@@ -61,19 +53,10 @@ type ButtonProps = {
6153
* Function to be called when button is clicked.
6254
*/
6355
onClick?: () => void | undefined;
64-
/**
65-
* Sets the tab index order of the base element.
66-
*/
67-
tabIndex?: string | number;
6856
/**
6957
* Sets the button color theme.
7058
*/
7159
theme?: 'primary' | 'secondary';
72-
/**
73-
* Applies a button type to the base element.
74-
*/
75-
type?: 'button' | 'reset' | 'submit';
76-
datum?: any;
7760
} & React.ButtonHTMLAttributes<HTMLButtonElement>;
7861

7962
export default function Button({
@@ -89,7 +72,6 @@ export default function Button({
8972
tabIndex = 0,
9073
theme = 'primary',
9174
type = 'button',
92-
datum = '',
9375
...rest
9476
}: ButtonProps) {
9577
const customDataAttributes = getDataAttributes(rest);
@@ -100,11 +82,6 @@ export default function Button({
10082
label: typeof children === 'string' ? children : undefined,
10183
};
10284

103-
const clickHandler = () => {
104-
gtag.event(eventConfig);
105-
onClick();
106-
};
107-
10885
return (
10986
<button
11087
className={classNames(styles.Button, className, styles[theme], {
@@ -113,7 +90,10 @@ export default function Button({
11390
})}
11491
data-testid={BUTTON}
11592
disabled={disabled}
116-
onClick={clickHandler}
93+
onClick={() => {
94+
gtag.event(eventConfig);
95+
onClick();
96+
}}
11797
tabIndex={tabIndex}
11898
type={type}
11999
{...customDataAttributes}

jest.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ module.exports = {
155155
// testLocationInResults: false,
156156

157157
// The glob patterns Jest uses to detect test files
158-
testMatch: ['<rootDir>/**/*.test.js', '<rootDir>/**/*.test.tsx'],
158+
testMatch: [
159+
'<rootDir>/**/*.test.js',
160+
'<rootDir>/**/*.test.jsx',
161+
'<rootDir>/**/*.test.ts',
162+
'<rootDir>/**/*.test.tsx',
163+
],
159164

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

0 commit comments

Comments
 (0)