@oanda/labs-spread-cost-calculator-widget 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/dist/main/SpreadCostCalculatorWidget/Main.js +23 -23
  3. package/dist/main/SpreadCostCalculatorWidget/Main.js.map +1 -1
  4. package/dist/main/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js +12 -12
  5. package/dist/main/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js.map +1 -1
  6. package/dist/main/SpreadCostCalculatorWidget/ValidationWrapper.js +5 -4
  7. package/dist/main/SpreadCostCalculatorWidget/ValidationWrapper.js.map +1 -1
  8. package/dist/main/SpreadCostCalculatorWidget/render.js +4 -4
  9. package/dist/main/SpreadCostCalculatorWidget/render.js.map +1 -1
  10. package/dist/main/SpreadCostCalculatorWidget/types.js.map +1 -1
  11. package/dist/main/SpreadCostCalculatorWidget/useCalculateSpread.js +3 -3
  12. package/dist/main/SpreadCostCalculatorWidget/useCalculateSpread.js.map +1 -1
  13. package/dist/main/SpreadCostCalculatorWidget/useInstrumentChange.js +1 -1
  14. package/dist/main/SpreadCostCalculatorWidget/useInstrumentChange.js.map +1 -1
  15. package/dist/main/SpreadCostCalculatorWidget/utils.js.map +1 -1
  16. package/dist/main/gql/types/fragment-masking.js +3 -2
  17. package/dist/main/gql/types/fragment-masking.js.map +1 -1
  18. package/dist/main/gql/types/gql.js +3 -2
  19. package/dist/main/gql/types/gql.js.map +1 -1
  20. package/dist/main/gql/types/graphql.js +71 -71
  21. package/dist/main/gql/types/graphql.js.map +1 -1
  22. package/dist/main/gql/types/index.js.map +1 -1
  23. package/dist/main/gql/validateInstruments.js +3 -8
  24. package/dist/main/gql/validateInstruments.js.map +1 -1
  25. package/dist/main/index.js +8 -8
  26. package/dist/main/index.js.map +1 -1
  27. package/dist/main/translations/index.js +1 -1
  28. package/dist/main/translations/index.js.map +1 -1
  29. package/dist/module/SpreadCostCalculatorWidget/Main.js +23 -23
  30. package/dist/module/SpreadCostCalculatorWidget/Main.js.map +1 -1
  31. package/dist/module/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js +12 -12
  32. package/dist/module/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js.map +1 -1
  33. package/dist/module/SpreadCostCalculatorWidget/ValidationWrapper.js +5 -4
  34. package/dist/module/SpreadCostCalculatorWidget/ValidationWrapper.js.map +1 -1
  35. package/dist/module/SpreadCostCalculatorWidget/render.js +4 -4
  36. package/dist/module/SpreadCostCalculatorWidget/render.js.map +1 -1
  37. package/dist/module/SpreadCostCalculatorWidget/types.js.map +1 -1
  38. package/dist/module/SpreadCostCalculatorWidget/useCalculateSpread.js +3 -3
  39. package/dist/module/SpreadCostCalculatorWidget/useCalculateSpread.js.map +1 -1
  40. package/dist/module/SpreadCostCalculatorWidget/useInstrumentChange.js +1 -1
  41. package/dist/module/SpreadCostCalculatorWidget/useInstrumentChange.js.map +1 -1
  42. package/dist/module/SpreadCostCalculatorWidget/utils.js.map +1 -1
  43. package/dist/module/gql/types/fragment-masking.js +3 -2
  44. package/dist/module/gql/types/fragment-masking.js.map +1 -1
  45. package/dist/module/gql/types/gql.js +3 -2
  46. package/dist/module/gql/types/gql.js.map +1 -1
  47. package/dist/module/gql/types/graphql.js +71 -71
  48. package/dist/module/gql/types/graphql.js.map +1 -1
  49. package/dist/module/gql/types/index.js +2 -2
  50. package/dist/module/gql/types/index.js.map +1 -1
  51. package/dist/module/gql/validateInstruments.js +3 -8
  52. package/dist/module/gql/validateInstruments.js.map +1 -1
  53. package/dist/module/index.js +1 -1
  54. package/dist/module/index.js.map +1 -1
  55. package/dist/module/translations/index.js +1 -1
  56. package/dist/module/translations/index.js.map +1 -1
  57. package/dist/types/SpreadCostCalculatorWidget/Main.d.ts +2 -2
  58. package/dist/types/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.d.ts +2 -2
  59. package/dist/types/SpreadCostCalculatorWidget/ValidationWrapper.d.ts +1 -1
  60. package/dist/types/SpreadCostCalculatorWidget/types.d.ts +6 -6
  61. package/dist/types/SpreadCostCalculatorWidget/useCalculateSpread.d.ts +3 -3
  62. package/dist/types/SpreadCostCalculatorWidget/useInstrumentChange.d.ts +3 -3
  63. package/dist/types/gql/types/gql.d.ts +2 -2
  64. package/dist/types/gql/types/index.d.ts +2 -2
  65. package/dist/types/index.d.ts +1 -1
  66. package/dist/types/translations/index.d.ts +2 -2
  67. package/package.json +3 -3
  68. package/src/SpreadCostCalculatorWidget/Main.tsx +32 -26
  69. package/src/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.tsx +12 -14
  70. package/src/SpreadCostCalculatorWidget/ValidationWrapper.tsx +24 -19
  71. package/src/SpreadCostCalculatorWidget/render.tsx +12 -12
  72. package/src/SpreadCostCalculatorWidget/types.ts +7 -6
  73. package/src/SpreadCostCalculatorWidget/useCalculateSpread.ts +25 -18
  74. package/src/SpreadCostCalculatorWidget/useInstrumentChange.ts +13 -7
  75. package/src/SpreadCostCalculatorWidget/utils.ts +2 -1
  76. package/src/gql/types/fragment-masking.ts +41 -21
  77. package/src/gql/types/gql.ts +7 -3
  78. package/src/gql/types/graphql.ts +126 -47
  79. package/src/gql/types/index.ts +2 -2
  80. package/src/index.ts +1 -1
  81. package/src/translations/index.ts +4 -4
  82. package/test/SpreadCostCalculator.test.tsx +8 -8
  83. package/test/useCalculateSpread.test.tsx +41 -34
  84. package/test/useInstrumentChange.test.tsx +11 -4
@@ -13,7 +13,8 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
13
13
  * Therefore it is highly recommended to use the babel or swc plugin for production.
14
14
  */
15
15
  const documents = {
16
- "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n": types.ValidateInstrumentsDocument,
16
+ '\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n':
17
+ types.ValidateInstrumentsDocument,
17
18
  };
18
19
 
19
20
  /**
@@ -33,10 +34,13 @@ export function graphql(source: string): unknown;
33
34
  /**
34
35
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
35
36
  */
36
- export function graphql(source: "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n"): (typeof documents)["\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n"];
37
+ export function graphql(
38
+ source: '\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n'
39
+ ): (typeof documents)['\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n'];
37
40
 
38
41
  export function graphql(source: string) {
39
42
  return (documents as any)[source] ?? {};
40
43
  }
41
44
 
42
- export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;
45
+ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> =
46
+ TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
@@ -2,18 +2,31 @@
2
2
  import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
3
3
  export type Maybe<T> = T | null;
4
4
  export type InputMaybe<T> = Maybe<T>;
5
- export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
6
- export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
7
- export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
8
- export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
9
- export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
5
+ export type Exact<T extends { [key: string]: unknown }> = {
6
+ [K in keyof T]: T[K];
7
+ };
8
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
9
+ [SubKey in K]?: Maybe<T[SubKey]>;
10
+ };
11
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
12
+ [SubKey in K]: Maybe<T[SubKey]>;
13
+ };
14
+ export type MakeEmpty<
15
+ T extends { [key: string]: unknown },
16
+ K extends keyof T,
17
+ > = { [_ in K]?: never };
18
+ export type Incremental<T> =
19
+ | T
20
+ | {
21
+ [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never;
22
+ };
10
23
  /** All built-in and custom scalars, mapped to their actual values */
11
24
  export type Scalars = {
12
- ID: { input: string; output: string; }
13
- String: { input: string; output: string; }
14
- Boolean: { input: boolean; output: boolean; }
15
- Int: { input: number; output: number; }
16
- Float: { input: number; output: number; }
25
+ ID: { input: string; output: string };
26
+ String: { input: string; output: string };
27
+ Boolean: { input: boolean; output: boolean };
28
+ Int: { input: number; output: number };
29
+ Float: { input: number; output: number };
17
30
  };
18
31
 
19
32
  export type AssetClass = {
@@ -28,12 +41,12 @@ export enum AssetClassName {
28
41
  Currency = 'CURRENCY',
29
42
  EquityShares = 'EQUITY_SHARES',
30
43
  Indices = 'INDICES',
31
- Rates = 'RATES'
44
+ Rates = 'RATES',
32
45
  }
33
46
 
34
47
  export enum BookType {
35
48
  Order = 'ORDER',
36
- Position = 'POSITION'
49
+ Position = 'POSITION',
37
50
  }
38
51
 
39
52
  export type CorrelationHeatmap = {
@@ -56,7 +69,7 @@ export enum CorrelationTimeUnit {
56
69
  M3 = 'M3',
57
70
  M6 = 'M6',
58
71
  W1 = 'W1',
59
- Y1 = 'Y1'
72
+ Y1 = 'Y1',
60
73
  }
61
74
 
62
75
  export enum CurrencyName {
@@ -67,7 +80,7 @@ export enum CurrencyName {
67
80
  Gbp = 'GBP',
68
81
  Jpy = 'JPY',
69
82
  Nzd = 'NZD',
70
- Usd = 'USD'
83
+ Usd = 'USD',
71
84
  }
72
85
 
73
86
  export type CurrencyPower = {
@@ -92,7 +105,7 @@ export enum CurrencyPowerBalanceTimeUnit {
92
105
  M1 = 'M1',
93
106
  M3 = 'M3',
94
107
  PreviousDay = 'PREVIOUS_DAY',
95
- W1 = 'W1'
108
+ W1 = 'W1',
96
109
  }
97
110
 
98
111
  export type CurrencyStrength = {
@@ -104,7 +117,7 @@ export type CurrencyStrength = {
104
117
 
105
118
  export enum DataSource {
106
119
  Ny4 = 'NY4',
107
- Ty3 = 'TY3'
120
+ Ty3 = 'TY3',
108
121
  }
109
122
 
110
123
  export enum Division {
@@ -116,7 +129,7 @@ export enum Division {
116
129
  Ogm = 'OGM',
117
130
  Oj = 'OJ',
118
131
  Opt = 'OPT',
119
- Otms = 'OTMS'
132
+ Otms = 'OTMS',
120
133
  }
121
134
 
122
135
  export type Heatmap = {
@@ -184,41 +197,34 @@ export type Query = {
184
197
  volatilityChartAssetClasses?: Maybe<Array<AssetClass>>;
185
198
  };
186
199
 
187
-
188
200
  export type QueryAssetClassesArgs = {
189
201
  division: Division;
190
202
  };
191
203
 
192
-
193
204
  export type QueryCorrelationHeatmapArgs = {
194
205
  division: Division;
195
206
  instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
196
207
  timeSpans?: InputMaybe<Array<InputMaybe<CorrelationTimeUnit>>>;
197
208
  };
198
209
 
199
-
200
210
  export type QueryCorrelationMatrixArgs = {
201
211
  division: Division;
202
212
  instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
203
213
  };
204
214
 
205
-
206
215
  export type QueryCurrencyPowerBalanceArgs = {
207
216
  timeUnit: CurrencyPowerBalanceTimeUnit;
208
217
  };
209
218
 
210
-
211
219
  export type QueryIsAllowedPartnerArgs = {
212
220
  url: Scalars['String']['input'];
213
221
  };
214
222
 
215
-
216
223
  export type QueryMapInstrumentNamesArgs = {
217
224
  division?: InputMaybe<Division>;
218
225
  instruments: Array<InputMaybe<Scalars['String']['input']>>;
219
226
  };
220
227
 
221
-
222
228
  export type QueryOrderPositionBooksArgs = {
223
229
  bookType: BookType;
224
230
  dataSource?: InputMaybe<DataSource>;
@@ -227,25 +233,21 @@ export type QueryOrderPositionBooksArgs = {
227
233
  region?: InputMaybe<Region>;
228
234
  };
229
235
 
230
-
231
236
  export type QueryResolveInstrumentsByDivisionArgs = {
232
237
  division: Division;
233
238
  instruments: Array<InputMaybe<Scalars['String']['input']>>;
234
239
  };
235
240
 
236
-
237
241
  export type QuerySentimentArgs = {
238
242
  division?: InputMaybe<Division>;
239
243
  name: Scalars['String']['input'];
240
244
  };
241
245
 
242
-
243
246
  export type QuerySentimentListArgs = {
244
247
  division?: InputMaybe<Division>;
245
248
  sort?: InputMaybe<Sort>;
246
249
  };
247
250
 
248
-
249
251
  export type QueryTopicalInstrumentsArgs = {
250
252
  assetClass?: InputMaybe<AssetClassName>;
251
253
  count?: InputMaybe<Scalars['Int']['input']>;
@@ -254,25 +256,21 @@ export type QueryTopicalInstrumentsArgs = {
254
256
  sort: TopicalSort;
255
257
  };
256
258
 
257
-
258
259
  export type QueryTopicalInstrumentsChartsArgs = {
259
260
  division?: InputMaybe<Division>;
260
261
  instruments?: InputMaybe<Array<Scalars['String']['input']>>;
261
262
  };
262
263
 
263
-
264
264
  export type QueryTopicalInstrumentsTotalCountArgs = {
265
265
  assetClass?: InputMaybe<AssetClassName>;
266
266
  division?: InputMaybe<Division>;
267
267
  sort: TopicalSort;
268
268
  };
269
269
 
270
-
271
270
  export type QueryValueAtRiskAssetClassesArgs = {
272
271
  division?: InputMaybe<Division>;
273
272
  };
274
273
 
275
-
276
274
  export type QueryValueAtRiskChartArgs = {
277
275
  bars: ValueAtRiskBars;
278
276
  division?: InputMaybe<Division>;
@@ -280,7 +278,6 @@ export type QueryValueAtRiskChartArgs = {
280
278
  instrument: Scalars['String']['input'];
281
279
  };
282
280
 
283
-
284
281
  export type QueryVolatilityChartArgs = {
285
282
  division?: InputMaybe<Division>;
286
283
  instrument: Scalars['String']['input'];
@@ -288,7 +285,6 @@ export type QueryVolatilityChartArgs = {
288
285
  timeUnit: VolatilityChartTimeUnit;
289
286
  };
290
287
 
291
-
292
288
  export type QueryVolatilityChartAssetClassesArgs = {
293
289
  division?: InputMaybe<Division>;
294
290
  };
@@ -296,7 +292,7 @@ export type QueryVolatilityChartAssetClassesArgs = {
296
292
  export enum Region {
297
293
  Amer = 'AMER',
298
294
  Apac = 'APAC',
299
- Emea = 'EMEA'
295
+ Emea = 'EMEA',
300
296
  }
301
297
 
302
298
  export type Sentiment = {
@@ -315,7 +311,7 @@ export type SentimentInstrument = {
315
311
 
316
312
  export enum Sort {
317
313
  Bearish = 'BEARISH',
318
- Bullish = 'BULLISH'
314
+ Bullish = 'BULLISH',
319
315
  }
320
316
 
321
317
  export type StrengthRelation = {
@@ -350,13 +346,13 @@ export enum TopicalSort {
350
346
  Bullish = 'BULLISH',
351
347
  Hot = 'HOT',
352
348
  Popular = 'POPULAR',
353
- Volatile = 'VOLATILE'
349
+ Volatile = 'VOLATILE',
354
350
  }
355
351
 
356
352
  export enum ValueAtRiskBars {
357
353
  C100 = 'C100',
358
354
  C200 = 'C200',
359
- C300 = 'C300'
355
+ C300 = 'C300',
360
356
  }
361
357
 
362
358
  export type ValueAtRiskChart = {
@@ -386,7 +382,7 @@ export enum ValueAtRiskDuration {
386
382
  C3 = 'C3',
387
383
  C4 = 'C4',
388
384
  C5 = 'C5',
389
- C10 = 'C10'
385
+ C10 = 'C10',
390
386
  }
391
387
 
392
388
  export type VolatilityChart = {
@@ -409,22 +405,105 @@ export enum VolatilityChartTimeSpan {
409
405
  /** Valid for: W */
410
406
  W5 = 'W5',
411
407
  /** Valid for: W */
412
- W10 = 'W10'
408
+ W10 = 'W10',
413
409
  }
414
410
 
415
411
  export enum VolatilityChartTimeUnit {
416
412
  D = 'D',
417
413
  H = 'H',
418
- W = 'W'
414
+ W = 'W',
419
415
  }
420
416
 
421
417
  export type ValidateInstrumentsQueryVariables = Exact<{
422
- instruments: Array<InputMaybe<Scalars['String']['input']>> | InputMaybe<Scalars['String']['input']>;
418
+ instruments:
419
+ | Array<InputMaybe<Scalars['String']['input']>>
420
+ | InputMaybe<Scalars['String']['input']>;
423
421
  division?: InputMaybe<Division>;
424
422
  }>;
425
423
 
426
-
427
- export type ValidateInstrumentsQuery = { __typename?: 'Query', mapInstrumentNames?: Array<{ __typename?: 'Instrument', name: string, displayName: string } | null> | null };
428
-
429
-
430
- export const ValidateInstrumentsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"validateInstruments"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"instruments"}},"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"division"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Division"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"mapInstrumentNames"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"instruments"},"value":{"kind":"Variable","name":{"kind":"Name","value":"instruments"}}},{"kind":"Argument","name":{"kind":"Name","value":"division"},"value":{"kind":"Variable","name":{"kind":"Name","value":"division"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}}]}}]}}]} as unknown as DocumentNode<ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables>;
424
+ export type ValidateInstrumentsQuery = {
425
+ __typename?: 'Query';
426
+ mapInstrumentNames?: Array<{
427
+ __typename?: 'Instrument';
428
+ name: string;
429
+ displayName: string;
430
+ } | null> | null;
431
+ };
432
+
433
+ export const ValidateInstrumentsDocument = {
434
+ kind: 'Document',
435
+ definitions: [
436
+ {
437
+ kind: 'OperationDefinition',
438
+ operation: 'query',
439
+ name: { kind: 'Name', value: 'validateInstruments' },
440
+ variableDefinitions: [
441
+ {
442
+ kind: 'VariableDefinition',
443
+ variable: {
444
+ kind: 'Variable',
445
+ name: { kind: 'Name', value: 'instruments' },
446
+ },
447
+ type: {
448
+ kind: 'NonNullType',
449
+ type: {
450
+ kind: 'ListType',
451
+ type: {
452
+ kind: 'NamedType',
453
+ name: { kind: 'Name', value: 'String' },
454
+ },
455
+ },
456
+ },
457
+ },
458
+ {
459
+ kind: 'VariableDefinition',
460
+ variable: {
461
+ kind: 'Variable',
462
+ name: { kind: 'Name', value: 'division' },
463
+ },
464
+ type: {
465
+ kind: 'NamedType',
466
+ name: { kind: 'Name', value: 'Division' },
467
+ },
468
+ },
469
+ ],
470
+ selectionSet: {
471
+ kind: 'SelectionSet',
472
+ selections: [
473
+ {
474
+ kind: 'Field',
475
+ name: { kind: 'Name', value: 'mapInstrumentNames' },
476
+ arguments: [
477
+ {
478
+ kind: 'Argument',
479
+ name: { kind: 'Name', value: 'instruments' },
480
+ value: {
481
+ kind: 'Variable',
482
+ name: { kind: 'Name', value: 'instruments' },
483
+ },
484
+ },
485
+ {
486
+ kind: 'Argument',
487
+ name: { kind: 'Name', value: 'division' },
488
+ value: {
489
+ kind: 'Variable',
490
+ name: { kind: 'Name', value: 'division' },
491
+ },
492
+ },
493
+ ],
494
+ selectionSet: {
495
+ kind: 'SelectionSet',
496
+ selections: [
497
+ { kind: 'Field', name: { kind: 'Name', value: 'name' } },
498
+ { kind: 'Field', name: { kind: 'Name', value: 'displayName' } },
499
+ ],
500
+ },
501
+ },
502
+ ],
503
+ },
504
+ },
505
+ ],
506
+ } as unknown as DocumentNode<
507
+ ValidateInstrumentsQuery,
508
+ ValidateInstrumentsQueryVariables
509
+ >;
@@ -1,2 +1,2 @@
1
- export * from "./fragment-masking";
2
- export * from "./gql";
1
+ export * from './fragment-masking';
2
+ export * from './gql';
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './SpreadCostCalculatorWidget/types';
2
1
  export * from './SpreadCostCalculatorWidget/SpreadCostCalculatorWidget';
2
+ export * from './SpreadCostCalculatorWidget/types';
@@ -1,11 +1,11 @@
1
- import { Locale, Translations } from '@oanda/mono-i18n';
1
+ import type { Translations } from '@oanda/mono-i18n';
2
+ import { Locale } from '@oanda/mono-i18n';
2
3
 
3
4
  import en from './sources/en.json';
4
- import zhTW from './sources/zh_TW.json';
5
5
  import es from './sources/es.json';
6
6
  import th from './sources/th.json';
7
-
8
- import { defaultTranslations } from './translations';
7
+ import zhTW from './sources/zh_TW.json';
8
+ import type { defaultTranslations } from './translations';
9
9
 
10
10
  export type TranslationKey = keyof typeof defaultTranslations;
11
11
 
@@ -2,11 +2,13 @@
2
2
  * @jest-environment jsdom
3
3
  */
4
4
 
5
- /* eslint-disable react/jsx-props-no-spreading */
6
-
7
- import React from 'react';
5
+ import {
6
+ LiveRatesProvider,
7
+ MockLayoutProvider,
8
+ } from '@oanda/labs-widget-common';
8
9
  import { render } from '@testing-library/react';
9
- import { LiveRatesProvider, MockLayoutProvider } from '@oanda/labs-widget-common';
10
+ import React from 'react';
11
+
10
12
  import { Main } from '../src/SpreadCostCalculatorWidget/Main';
11
13
 
12
14
  describe('Spread Cost Calculator', () => {
@@ -23,11 +25,9 @@ describe('Spread Cost Calculator', () => {
23
25
  const { findByTestId } = render(
24
26
  <LiveRatesProvider url="oanda.com">
25
27
  <MockLayoutProvider>
26
- <Main
27
- instruments={[{ name: 'EUR_USD', displayName: 'EUR/USD' }]}
28
- />
28
+ <Main instruments={[{ name: 'EUR_USD', displayName: 'EUR/USD' }]} />
29
29
  </MockLayoutProvider>
30
- </LiveRatesProvider>,
30
+ </LiveRatesProvider>
31
31
  );
32
32
 
33
33
  // Then
@@ -3,10 +3,9 @@
3
3
  */
4
4
 
5
5
  import { act, renderHook } from '@testing-library/react';
6
- import {
7
- useCalculateSpread,
8
- UseCalculateSpreadInput,
9
- } from '../src/SpreadCostCalculatorWidget/useCalculateSpread';
6
+
7
+ import type { UseCalculateSpreadInput } from '../src/SpreadCostCalculatorWidget/useCalculateSpread';
8
+ import { useCalculateSpread } from '../src/SpreadCostCalculatorWidget/useCalculateSpread';
10
9
 
11
10
  describe('spread cost calculator', () => {
12
11
  describe('useCalculateSpread', () => {
@@ -33,17 +32,17 @@ describe('spread cost calculator', () => {
33
32
  { ...input, pipLocation: undefined },
34
33
  ])(
35
34
  'should return undefined, when one of params is undefined (%s)',
36
- ({
37
- unitsTraded, spread, pipLocation, currency,
38
- }) => {
35
+ ({ unitsTraded, spread, pipLocation, currency }) => {
39
36
  // Given
40
37
  // When
41
- const { result } = renderHook(() => useCalculateSpread({
42
- spread,
43
- unitsTraded,
44
- pipLocation,
45
- currency,
46
- }));
38
+ const { result } = renderHook(() =>
39
+ useCalculateSpread({
40
+ spread,
41
+ unitsTraded,
42
+ pipLocation,
43
+ currency,
44
+ })
45
+ );
47
46
 
48
47
  expect(result.current).toBe('\u2014');
49
48
 
@@ -53,17 +52,19 @@ describe('spread cost calculator', () => {
53
52
 
54
53
  // Then
55
54
  expect(result.current).toBe('\u2014');
56
- },
55
+ }
57
56
  );
58
57
 
59
58
  it('should return correct calculated values', () => {
60
59
  // Given
61
60
  // When
62
- const { result } = renderHook(() => useCalculateSpread({
63
- ...input,
64
- spread: 2,
65
- pipLocation: -4,
66
- }));
61
+ const { result } = renderHook(() =>
62
+ useCalculateSpread({
63
+ ...input,
64
+ spread: 2,
65
+ pipLocation: -4,
66
+ })
67
+ );
67
68
 
68
69
  expect(result.current).toBe('\u2014');
69
70
 
@@ -78,11 +79,13 @@ describe('spread cost calculator', () => {
78
79
  it('should return correct calculated values with 0 as pipLocation', () => {
79
80
  // Given
80
81
  // When
81
- const { result } = renderHook(() => useCalculateSpread({
82
- ...input,
83
- spread: 2,
84
- pipLocation: 0,
85
- }));
82
+ const { result } = renderHook(() =>
83
+ useCalculateSpread({
84
+ ...input,
85
+ spread: 2,
86
+ pipLocation: 0,
87
+ })
88
+ );
86
89
 
87
90
  expect(result.current).toBe('\u2014');
88
91
 
@@ -97,11 +100,13 @@ describe('spread cost calculator', () => {
97
100
  it('should round up result to 4 decimal places', () => {
98
101
  // Given
99
102
  // When
100
- const { result } = renderHook(() => useCalculateSpread({
101
- ...input,
102
- unitsTraded: 4,
103
- spread: 1.1,
104
- }));
103
+ const { result } = renderHook(() =>
104
+ useCalculateSpread({
105
+ ...input,
106
+ unitsTraded: 4,
107
+ spread: 1.1,
108
+ })
109
+ );
105
110
 
106
111
  expect(result.current).toBe('\u2014');
107
112
 
@@ -116,11 +121,13 @@ describe('spread cost calculator', () => {
116
121
  it('should calculate big numbers', () => {
117
122
  // Given
118
123
  // When
119
- const { result } = renderHook(() => useCalculateSpread({
120
- ...input,
121
- unitsTraded: 1122342,
122
- spread: 123331,
123
- }));
124
+ const { result } = renderHook(() =>
125
+ useCalculateSpread({
126
+ ...input,
127
+ unitsTraded: 1122342,
128
+ spread: 123331,
129
+ })
130
+ );
124
131
 
125
132
  expect(result.current).toBe('\u2014');
126
133
 
@@ -2,12 +2,15 @@
2
2
  * @jest-environment jsdom
3
3
  */
4
4
 
5
+ import {
6
+ useLiveRatesMessage,
7
+ useLiveRatesQuery,
8
+ } from '@oanda/labs-widget-common';
5
9
  import { renderHook } from '@testing-library/react';
6
- import { useLiveRatesMessage, useLiveRatesQuery } from '@oanda/labs-widget-common';
10
+
7
11
  import { useInstrumentChange } from '../src/SpreadCostCalculatorWidget/useInstrumentChange';
8
12
 
9
13
  jest.mock('@oanda/labs-widget-common', () => ({
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
14
  ...jest.requireActual('@oanda/labs-widget-common'),
12
15
  useLiveRatesQuery: jest.fn(),
13
16
  useLiveRatesMessage: jest.fn(),
@@ -26,7 +29,9 @@ describe('useInstrumentChange', () => {
26
29
  update: undefined,
27
30
  });
28
31
 
29
- const { result } = renderHook(() => useInstrumentChange({ initialInstrument }));
32
+ const { result } = renderHook(() =>
33
+ useInstrumentChange({ initialInstrument })
34
+ );
30
35
 
31
36
  expect(result.current.selectedInstrument).toEqual(initialInstrument);
32
37
  expect(result.current.pipLocation).toBe(undefined);
@@ -46,7 +51,9 @@ describe('useInstrumentChange', () => {
46
51
  update: updateMock,
47
52
  });
48
53
 
49
- const { result } = renderHook(() => useInstrumentChange({ initialInstrument }));
54
+ const { result } = renderHook(() =>
55
+ useInstrumentChange({ initialInstrument })
56
+ );
50
57
 
51
58
  expect(result.current.pipLocation).toBe(-4);
52
59
  expect(result.current.initialSpread).toBe(1.2);