Skip to content

Commit

Permalink
Merge pull request #42 from suisin-deriv/suisin/74157/ts_migration_se…
Browse files Browse the repository at this point in the history
…lf_exclusion_article

refactor: ts migration for self-exclusion-article
  • Loading branch information
niloofar-deriv committed Jan 19, 2023
2 parents 0360500 + e83058c commit cf90488
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@ jest.mock('Components/self-exclusion/self-exclusion-article-content', () => ({
}));

describe('<SelfExclusionArticle />', () => {
let mock_platform_context = {};
let mock_self_exclusion_context = {};
let mock_platform_context = {
is_appstore: false,
is_deriv_crypto: false,
};
let mock_self_exclusion_context = {
is_app_settings: false,
is_eu: false,
is_uk: false,
overlay_ref: {},
toggleArticle: jest.fn(),
};

const eu_item =
/these trading limits and self-exclusion help you control the amount of money and time you spend on deriv.com and exercise/i;
Expand All @@ -40,11 +49,11 @@ describe('<SelfExclusionArticle />', () => {
});

it('should render SelfExclusionArticle desktop component with selfExclusionArticleItems', () => {
isDesktop.mockReturnValueOnce(true);
isMobile.mockReturnValueOnce(false);
(isDesktop as jest.Mock).mockReturnValueOnce(true);
(isMobile as jest.Mock).mockReturnValueOnce(false);
mock_platform_context.is_appstore = true;

selfExclusionArticleItems.mockImplementation(() => ['Self Exclusion Article Items']);
(selfExclusionArticleItems as jest.Mock).mockImplementation(() => ['Self Exclusion Article Items']);

render(
<PlatformContext.Provider value={mock_platform_context}>
Expand Down Expand Up @@ -78,8 +87,8 @@ describe('<SelfExclusionArticle />', () => {

it('should render SelfExclusionArticle desktop component for non EU items', () => {
mock_platform_context.is_appstore = true;
isDesktop.mockReturnValueOnce(false);
isMobile.mockReturnValueOnce(false);
(isDesktop as jest.Mock).mockReturnValueOnce(false);
(isMobile as jest.Mock).mockReturnValueOnce(false);

render(
<PlatformContext.Provider value={mock_platform_context}>
Expand All @@ -95,8 +104,8 @@ describe('<SelfExclusionArticle />', () => {
});

it('should render SelfExclusionArticle mobile component and trigger click', () => {
isDesktop.mockReturnValueOnce(false);
isMobile.mockReturnValueOnce(true);
(isDesktop as jest.Mock).mockReturnValueOnce(false);
(isMobile as jest.Mock).mockReturnValueOnce(true);
const mockToggleArticle = mock_self_exclusion_context.toggleArticle;

render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import classNames from 'classnames';
import { isDesktop, isMobile } from '@deriv/shared';
import { Div100vhContainer, ThemedScrollbars } from '@deriv/components';
import SelfExclusionArticle from './self-exclusion-article.jsx';
import SelfExclusionArticle from './self-exclusion-article';
import SelfExclusionContext from './self-exclusion-context';

const SelfExclusionWrapper = ({ children }: { children?: React.ReactNode }) => {
Expand Down

0 comments on commit cf90488

Please sign in to comment.