Skip to content

Commit efa30dd

Browse files
committed
Fix tests
1 parent c8a5ba6 commit efa30dd

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎tests/builtInIndicator.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import utils from './utils';
44

55
describe('BuiltInIndicator', () => {
66
let client: TradingView.Client;
7-
let chart: any;
7+
let chart: InstanceType<typeof client.Session.Chart>;
88

99
it('creates a client', async () => {
1010
client = new TradingView.Client();

‎tests/indicators.test.ts‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Indicators', () => {
3333
});
3434

3535
let client: TradingView.Client;
36-
let chart: any;
36+
let chart: InstanceType<typeof client.Session.Chart>;
3737

3838
it('creates a client', async () => {
3939
client = new TradingView.Client();
@@ -71,16 +71,22 @@ describe('Indicators', () => {
7171

7272
console.log('Performances:', {
7373
total: {
74-
trades: perfReport.all.totalTrades,
75-
perf: `${Math.round(perfReport.all.netProfitPercent * 10000) / 100} %`,
74+
trades: perfReport?.all?.totalTrades,
75+
perf: `${Math.round((
76+
perfReport?.all?.netProfitPercent || 0
77+
) * 10000) / 100} %`,
7678
},
7779
buy: {
78-
trades: perfReport.long.totalTrades,
79-
perf: `${Math.round(perfReport.long.netProfitPercent * 10000) / 100} %`,
80+
trades: perfReport?.long?.totalTrades,
81+
perf: `${Math.round((
82+
perfReport?.long?.netProfitPercent || 0
83+
) * 10000) / 100} %`,
8084
},
8185
sell: {
82-
trades: perfReport.short.totalTrades,
83-
perf: `${Math.round(perfReport.short.netProfitPercent * 10000) / 100} %`,
86+
trades: perfReport?.short?.totalTrades,
87+
perf: `${Math.round((
88+
perfReport?.short?.netProfitPercent || 0
89+
) * 10000) / 100} %`,
8490
},
8591
});
8692

‎tests/replayMode.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import utils from './utils';
44

55
describe('ReplayMode', () => {
66
let client: TradingView.Client;
7-
let chart: any;
7+
let chart: InstanceType<typeof client.Session.Chart>;
88

99
it('creates a client', async () => {
1010
client = new TradingView.Client();

0 commit comments

Comments
 (0)