From a038f63ef1fde562f2a689eb1d601bed080b0065 Mon Sep 17 00:00:00 2001 From: tay suisin Date: Wed, 11 Jan 2023 16:15:41 +0800 Subject: [PATCH 1/3] refactor: ts migration for account limits article and tests --- ...mits-article.spec.js => account-limits-article.spec.tsx} | 5 +---- ...ccount-limits-article.jsx => account-limits-article.tsx} | 6 +++++- .../components/src/components/static-url/static-url.tsx | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) rename packages/account/src/Components/account-limits/__tests__/{account-limits-article.spec.js => account-limits-article.spec.tsx} (90%) rename packages/account/src/Components/account-limits/{account-limits-article.jsx => account-limits-article.tsx} (88%) diff --git a/packages/account/src/Components/account-limits/__tests__/account-limits-article.spec.js b/packages/account/src/Components/account-limits/__tests__/account-limits-article.spec.tsx similarity index 90% rename from packages/account/src/Components/account-limits/__tests__/account-limits-article.spec.js rename to packages/account/src/Components/account-limits/__tests__/account-limits-article.spec.tsx index c460f91b6532..028e6ab192c5 100644 --- a/packages/account/src/Components/account-limits/__tests__/account-limits-article.spec.js +++ b/packages/account/src/Components/account-limits/__tests__/account-limits-article.spec.tsx @@ -23,10 +23,7 @@ describe('', () => { it('should go to help-centre page if the Help Centre link on the text is clicked', () => { render(); - expect(screen.getByText('Help Centre.').closest('a')).toHaveAttribute( - 'href', - 'https://deriv.com/help-centre/trading/#trading-limits' - ); + expect(screen.getByText('Help Centre.').hasAttribute('href')); }); it('should show the descriptions for the account limit when is_from_derivgo is true', () => { diff --git a/packages/account/src/Components/account-limits/account-limits-article.jsx b/packages/account/src/Components/account-limits/account-limits-article.tsx similarity index 88% rename from packages/account/src/Components/account-limits/account-limits-article.jsx rename to packages/account/src/Components/account-limits/account-limits-article.tsx index 696327cebf7a..ab843d110855 100644 --- a/packages/account/src/Components/account-limits/account-limits-article.jsx +++ b/packages/account/src/Components/account-limits/account-limits-article.tsx @@ -4,7 +4,11 @@ import { StaticUrl } from '@deriv/components'; import { Localize, localize } from '@deriv/translations'; import AccountArticle from 'Components/article'; -const AccountLimitsArticle = ({ is_from_derivgo }) => { +type TAccountLimitsArticle = { + is_from_derivgo?: boolean; +}; + +const AccountLimitsArticle = ({ is_from_derivgo }: TAccountLimitsArticle) => { const getDescription = () => { const description = [ , diff --git a/packages/components/src/components/static-url/static-url.tsx b/packages/components/src/components/static-url/static-url.tsx index 1d0d5dcef238..474038358a87 100644 --- a/packages/components/src/components/static-url/static-url.tsx +++ b/packages/components/src/components/static-url/static-url.tsx @@ -7,7 +7,7 @@ export type TPlatformContext = { is_pre_appstore?: boolean; }; -type TStaticUrl = { +type TStaticUrl = React.HTMLAttributes & { href?: string; is_document?: boolean; }; From a5fc900dbf953e3e88c263b46f6c8b8a41ea1ace Mon Sep 17 00:00:00 2001 From: tay suisin Date: Wed, 11 Jan 2023 16:17:54 +0800 Subject: [PATCH 2/3] chore: remove all .jsx --- .../account/src/Components/account-limits/account-limits.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/account/src/Components/account-limits/account-limits.jsx b/packages/account/src/Components/account-limits/account-limits.jsx index 1871c9aa832c..cf4a52ca55c6 100644 --- a/packages/account/src/Components/account-limits/account-limits.jsx +++ b/packages/account/src/Components/account-limits/account-limits.jsx @@ -6,7 +6,7 @@ import { formatMoney, isDesktop, isMobile, useIsMounted, PlatformContext } from import { Localize, localize } from '@deriv/translations'; import LoadErrorMessage from 'Components/load-error-message'; import DemoMessage from 'Components/demo-message'; -import AccountLimitsArticle from './account-limits-article.jsx'; +import AccountLimitsArticle from './account-limits-article'; import AccountLimitsContext from './account-limits-context'; import AccountLimitsExtraInfo from './account-limits-extra-info'; import AccountLimitsFooter from './account-limits-footer'; From f6b32dd6fc01f8fcfb1f9437e3cb41ed66cad418 Mon Sep 17 00:00:00 2001 From: tay suisin Date: Thu, 12 Jan 2023 10:58:40 +0800 Subject: [PATCH 3/3] chore: change test case format --- .../account-limits/__tests__/account-limits-article.spec.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/account/src/Components/account-limits/__tests__/account-limits-article.spec.tsx b/packages/account/src/Components/account-limits/__tests__/account-limits-article.spec.tsx index 028e6ab192c5..077ca1f65445 100644 --- a/packages/account/src/Components/account-limits/__tests__/account-limits-article.spec.tsx +++ b/packages/account/src/Components/account-limits/__tests__/account-limits-article.spec.tsx @@ -23,7 +23,10 @@ describe('', () => { it('should go to help-centre page if the Help Centre link on the text is clicked', () => { render(); - expect(screen.getByText('Help Centre.').hasAttribute('href')); + expect(screen.getByText('Help Centre.')).toHaveAttribute( + 'href', + 'https://deriv.com/help-centre/trading/#trading-limits' + ); }); it('should show the descriptions for the account limit when is_from_derivgo is true', () => {