forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
maryia/DTRA-260/TS migration of /Constants files & SmartChart/Helpers files in Trader #6
Merged
kate-deriv
merged 15 commits into
kate-deriv:kate/ts_migration_trader_package
from
maryia-deriv:maryia/WEBREL-320/validation-rules-to-ts
Jul 5, 2023
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
96b4084
feat: validation-rules and ui.js to ts
maryia-deriv b0b8cee
chore: squash merge maryia/WEBREL-321/actions-to-TS changes
maryia-deriv e933555
chore: added types to validation-rules.ts
maryia-deriv 1dc1856
chore: remove unused ui.js, migrate used ui.js and index.js to ts
maryia-deriv f37fb63
chore: remove unused ui.js
maryia-deriv 44ed617
chore: remove unused markers.js, and migrate barriers.js to ts
maryia-deriv 5f573ba
chore: added types to barriers.js and its test
maryia-deriv 21b4eff
test: add missing test for removeBarrier to barriers
maryia-deriv 023336b
Revert "chore: squash merge maryia/WEBREL-321/actions-to-TS changes"
maryia-deriv 6f789a8
Merge branch 'kate/ts_migration_trader_package' of github.com:kate-de…
maryia-deriv 2a88d0e
feat: migrated chart-barrier-store.js to ts
maryia-deriv 6682205
feat: remove unused ChartMarkerStore
maryia-deriv 881765d
build: trigger build
maryia-deriv 5275b3d
Merge branch kate/ts_migration_trader_package of github.com:kate-deri…
maryia-deriv bef0ab3
fix: address review comments
maryia-deriv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
packages/trader/src/Stores/Modules/SmartChart/Constants/markers.js
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
packages/trader/src/Stores/Modules/SmartChart/Helpers/__tests__/barriers.js
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
packages/trader/src/Stores/Modules/SmartChart/Helpers/__tests__/barriers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as Barriers from '../barriers'; | ||
|
||
describe('Barriers', () => { | ||
describe('barriersToString', () => { | ||
it('should convert non-zero barriers which do not have +/- to string consisting of them without +/- while is_relative is false', () => { | ||
expect(Barriers.barriersToString(false, 10, 15)).toEqual(['10', '15']); | ||
}); | ||
it('should convert values without +/- and zero to string consisting of them without +/- while is_relative is false', () => { | ||
expect(Barriers.barriersToString(false, 0, 15)).toEqual(['0', '15']); | ||
}); | ||
it('should convert barriers which have +/- to string consisting of them without +/- while is_relative is false', () => { | ||
expect(Barriers.barriersToString(false, +11, 15)).toEqual(['11', '15']); | ||
}); | ||
it('should convert barriers which have +/- to string consisting of them with +/- while is_relative is true', () => { | ||
expect(Barriers.barriersToString(true, +11, +15)).toEqual(['+11', '+15']); | ||
}); | ||
}); | ||
describe('removeBarrier', () => { | ||
let barriers: Barriers.TBarrier[]; | ||
const BARRIERS_KEYS = { | ||
PURCHASE_SPOT_BARRIER: 'PURCHASE_SPOT_BARRIER', | ||
TAKE_PROFIT: 'take_profit', | ||
STOP_LOSS: 'stop_loss', | ||
STOP_OUT: 'stop_out', | ||
}; | ||
beforeEach(() => { | ||
barriers = [ | ||
{ key: BARRIERS_KEYS.PURCHASE_SPOT_BARRIER, high: '1111.11' }, | ||
{ key: BARRIERS_KEYS.TAKE_PROFIT, high: '2222.22' }, | ||
{ key: BARRIERS_KEYS.STOP_OUT, high: '3333.33' }, | ||
] as Barriers.TBarrier[]; | ||
}); | ||
it('should remove the barrier with a specified key from initial barriers array', () => { | ||
const key_to_remove = BARRIERS_KEYS.TAKE_PROFIT; | ||
Barriers.removeBarrier(barriers, key_to_remove); | ||
expect(barriers.find(barrier => barrier.key === key_to_remove)).toBeUndefined(); | ||
expect(barriers.length).toEqual(2); | ||
}); | ||
it('should not remove any barriers if the key is not found', () => { | ||
Barriers.removeBarrier(barriers, BARRIERS_KEYS.STOP_LOSS); | ||
expect(barriers.length).toEqual(3); | ||
}); | ||
it('should not modify the barriers array if it is empty', () => { | ||
const key_to_remove = BARRIERS_KEYS.STOP_OUT; | ||
const empty_barriers = [] as Barriers.TBarrier[]; | ||
Barriers.removeBarrier(empty_barriers, key_to_remove); | ||
expect(empty_barriers.length).toEqual(0); | ||
}); | ||
}); | ||
}); |
28 changes: 0 additions & 28 deletions
28
packages/trader/src/Stores/Modules/SmartChart/Helpers/barriers.js
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
packages/trader/src/Stores/Modules/SmartChart/Helpers/barriers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { ChartBarrierStore } from '../chart-barrier-store'; | ||
|
||
export type TBarrier = ChartBarrierStore & { key?: string }; | ||
|
||
export const barriersToString = ( | ||
is_relative: boolean, | ||
...barriers_list: Array<string | number | undefined> | ||
): Array<string | undefined> => | ||
barriers_list | ||
.filter(barrier => barrier !== undefined && barrier !== null) | ||
.map(barrier => `${is_relative && !/^[+-]/.test(`${barrier}`) ? '+' : ''}${barrier}`); | ||
|
||
export const removeBarrier = (barriers: TBarrier[], key: string) => { | ||
const index = barriers.findIndex(b => b.key === key); | ||
if (index > -1) { | ||
barriers.splice(index, 1); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
packages/trader/src/Stores/Modules/SmartChart/chart-marker-store.js
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/trader/src/Stores/Modules/Trading/Constants/ui.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for me i ended up adding key as a prop in chartbarrierstore in my PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henry-deriv the thing is that ChartBarrierStore has nothing to do with the key, the key is assigned afterwards to a resulting object which is returned as a result of
new ChartBarrierStore(...)
call.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the same change in my PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you🙏🏻