Skip to content

Commit

Permalink
Kate / WEBREL-477 / TS migration of trader package (deriv-com#9087)
Browse files Browse the repository at this point in the history
* refactor: ts migration of chart loader

* refactor: ts migration of screen large form and started purchase

* refactor: add types in store and refcator contract

* refactor: ts migaration of purchase field

* refactor: ts migration of cancel deal info

* refactor: ts migration of the purchase btn

* refactor: cancel deal info

* refactor: remove simular types

* refactor: create file for types

* chore: cover return value with react fragment

* refactor: apply suggestions

* refactor: update imports

* refactor: type returned value

* refactor: left an explanation of expecting ts error

* Akmal / feat: migrate EmptyPortfolioMessage, ErrorComponent and Page404 in Trader package (#5)

* feat: migrate Page404 to Typescript

* feat: migrate EmptyPortfolioMessage to Typescript

* feat: migrate ErrorComponent to Typescript

* fix: dialog prop

* fix: dialog type

* chore: remove React.FC

* maryia/WEBREL-321/feat: migrate Actions files to TS (#4)

* feat: migrate /contract-type.js to ts & remove barrier.js

* feat: migrate duration to ts + remove unused currency.js

* feat: migrate actions/purchase to ts

* feat: migrate actions/symbol to ts

* feat: migrate start-date.js to ts

* feat: migrate actions/test.js to ts

* chore: improve types in start-date and duration

* fix: address review comments

* revert: unnecessary line deletion

* fix: address reviews

* refactor: remove some code smells

* refactor: remove code smells

* refactor: update types in stores

* Akmal / feat: migrate utils in Trader package  (#9)

* feat: migrate MarketUnderlying to Typescript

* feat: migrate errors to Typescript

* feat: migrate error spec to Typescript

* feat: migrate index to Typescript

* feat: migrate validator to Typescript

* feat: trigger vercel

* chore: sort options alphabetically

* fix: TValidationResult type

* chore: prettier formatting

* refactor: reduce code smells

* chore: validator type improvements (#12)

* Kate / DTRA-249 / Code refactoring and removing duplicated files (#13)

* refactor: remove duplicated file

* refactor: test improvements

* fix: removed forgotten import

* chore: empty commit to retrigger checks

* refactor: apply suggestion

* maryia/DTRA-260/TS migration of /Constants files & SmartChart/Helpers files in Trader (#6)

* feat: validation-rules and ui.js to ts

* chore: squash merge maryia/WEBREL-321/actions-to-TS changes

* chore: added types to validation-rules.ts

* chore: remove unused ui.js, migrate used ui.js and index.js to ts

* chore: remove unused ui.js

* chore: remove unused markers.js, and migrate barriers.js to ts

* chore: added types to barriers.js and its test

* test: add missing test for removeBarrier to barriers

* Revert "chore: squash merge maryia/WEBREL-321/actions-to-TS changes"

* feat: migrated chart-barrier-store.js to ts

* feat: remove unused ChartMarkerStore

* build: trigger build

* fix: address review comments

* henry/webrel-319/ts-migration-modules-trading-helpers-folder (#11)

* fix: merge conflicts

* fix: resolve comments

* fix: remove comment

* fix: add loadash types dependency

* refactor: move error type to common props file

* fix: circle CI

* fix: resolve comment

* fix: bug

* fix: convert returntype to use ttradestore

* empty commit

* fix: type change

* fix: resolve comments

* fix: comments

* maryia/861n17c54/fix: sonarcloud warnings (#14)

* fix: sonarcloud warnings

* fix: types

* fix: resolve conflicts

* refactor: apply suggestions

* refactor: add last suggestion

* refactor: tests

* refactor: update function

* refactor: add ts migration of exist tests

* fix: tests

* fix: test case

---------

Co-authored-by: Akmal Djumakhodjaev <akmal@binary.com>
Co-authored-by: Maryia <103177211+maryia-deriv@users.noreply.github.com>
Co-authored-by: henry-deriv <118344354+henry-deriv@users.noreply.github.com>
Co-authored-by: Matin shafiei <matin@deriv.com>
  • Loading branch information
5 people authored Sep 7, 2023
1 parent 7331b89 commit 3c6fd23
Show file tree
Hide file tree
Showing 87 changed files with 1,701 additions and 1,776 deletions.
4 changes: 2 additions & 2 deletions packages/components/src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type TDialog = {
dismissable?: boolean;
disableApp?: () => void;
enableApp?: () => void;
has_close_icon: boolean;
has_close_icon?: boolean;
is_closed_on_cancel?: boolean;
is_closed_on_confirm?: boolean;
is_content_centered?: boolean;
Expand Down Expand Up @@ -98,7 +98,7 @@ const Dialog = ({
}
};

const validateClickOutside = () => dismissable || (has_close_icon && is_visible && is_closed_on_cancel);
const validateClickOutside = () => dismissable || !!(has_close_icon && is_visible && is_closed_on_cancel);

useOnClickOutside(wrapper_ref, handleClose, validateClickOutside);

Expand Down
248 changes: 0 additions & 248 deletions packages/core/src/Constants/contract.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/src/Constants/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './contract';
export * from './ui';
91 changes: 91 additions & 0 deletions packages/shared/src/utils/constants/__tests__/contract.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { localize } from '@deriv/translations';
import {
getCardLabels,
getMarketNamesMap,
getUnsupportedContracts,
getSupportedContracts,
getContractConfig,
getContractTypeDisplay,
getContractTypePosition,
} from '../contract';

type TGetSupportedContractsKey = keyof ReturnType<typeof getSupportedContracts>;
const card_label = localize('Apply');
const markets_name = localize('AUD/CAD');
const unsupported_contract = {
name: localize('Spread Up'),
position: 'top',
};
const supported_high_low = {
name: localize('Higher'),
position: 'top',
};
const not_supported_high_low = {
name: localize('Rise'),
position: 'top',
};

describe('getCardLabels', () => {
it('should return an object with card labels, e.g. such as Apply', () => {
expect(getCardLabels().APPLY).toEqual(card_label);
});
});

describe('getMarketNamesMap', () => {
it('should return an object with markets names, e.g. such as AUD/CAD', () => {
expect(getMarketNamesMap().FRXAUDCAD).toEqual(markets_name);
});
});

describe('getUnsupportedContracts', () => {
it('should return an object with unsupported contracts, e.g. such as Spread Up', () => {
expect(getUnsupportedContracts().CALLSPREAD).toEqual(unsupported_contract);
});
});

describe('getSupportedContracts', () => {
it('should return an object with specific supported contracts if is_high_low === true', () => {
expect(getSupportedContracts(true).CALL).toEqual(supported_high_low);
});

it('should return an object with specific supported contracts if is_high_low === false', () => {
expect(getSupportedContracts(false).CALL).toEqual(not_supported_high_low);
});
});

describe('getContractConfig', () => {
it('should return an object with specific contracts if is_high_low === true', () => {
expect(getContractConfig(true).CALL).toEqual(supported_high_low);
});

it('should return object with specific contracts if is_high_low === false', () => {
expect(getContractConfig(false).CALL).toEqual(not_supported_high_low);
});
});

describe('getContractTypeDisplay', () => {
it('should return a specific button name if show_button_name === true and contract_config has a button_name field', () => {
expect(getContractTypeDisplay('ACCU', false, true)).toEqual(localize('Buy'));
});
it('should return a specific contract name if show_button_name === false but contract_config has a button_name field', () => {
expect(getContractTypeDisplay('ACCU')).toEqual(localize('Accumulators'));
});
it('should return a specific contract name if show_button_name === true but contract_config has no button_name field', () => {
expect(getContractTypeDisplay('MULTDOWN', true, true)).toEqual(localize('Down'));
});
it('should return an empty string if show_button_name === false and contract_config has no name field', () => {
expect(getContractTypeDisplay('TEST', true, false)).toBe('');
});
it('should return an empty string if show_button_name === true and contract_config has no name field and no button_name', () => {
expect(getContractTypeDisplay('TEST', true, true)).toBe('');
});
});

describe('getContractTypePosition', () => {
it('should return a specific button position if such type exist', () => {
expect(getContractTypePosition('NOTOUCH')).toBe('bottom');
});
it('should return a top position if such type does not exist', () => {
expect(getContractTypePosition('TEST' as TGetSupportedContractsKey)).toBe('top');
});
});
Loading

0 comments on commit 3c6fd23

Please sign in to comment.