Skip to content

Commit 4a69f8f

Browse files
committed
Fix 'max number of studies...' error
1 parent 8254c15 commit 4a69f8f

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

tests/allErrors.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,7 @@ describe('AllErrors', () => {
159159
)('throws an error when setting an invalid study option value', async () => {
160160
console.log('Testing "Invalid value" error:');
161161

162-
const client = new TradingView.Client({
163-
token,
164-
signature,
165-
});
162+
const client = new TradingView.Client({ token, signature });
166163
const chart = new client.Session.Chart();
167164

168165
chart.setMarket('BINANCE:BTCEUR'); // Set a market

tests/indicators.test.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { describe, it, expect } from 'vitest';
22
import TradingView from '../main';
33

4+
const token = <string>process.env.SESSION;
5+
const signature = <string>process.env.SIGNATURE;
6+
47
describe('Indicators', () => {
58
const indicators: { [name: string]: TradingView.PineIndicator } = {};
69

@@ -35,17 +38,19 @@ describe('Indicators', () => {
3538
let client: TradingView.Client;
3639
let chart: InstanceType<typeof client.Session.Chart>;
3740

38-
it('creates a client', async () => {
39-
client = new TradingView.Client();
41+
const noAuth = !token || !signature;
42+
43+
it.skipIf(noAuth)('creates a client', async () => {
44+
client = new TradingView.Client({ token, signature });
4045
expect(client).toBeDefined();
4146
});
4247

43-
it('creates a chart', async () => {
48+
it.skipIf(noAuth)('creates a chart', async () => {
4449
chart = new client.Session.Chart();
4550
expect(chart).toBeDefined();
4651
});
4752

48-
it('sets market', async () => {
53+
it.skipIf(noAuth)('sets market', async () => {
4954
chart.setMarket('BINANCE:BTCEUR', {
5055
timeframe: '60',
5156
});
@@ -60,7 +65,7 @@ describe('Indicators', () => {
6065
expect(chart.infos.full_name).toBe('BINANCE:BTCEUR');
6166
});
6267

63-
it.concurrent('gets performance data from SuperTrend strategy', async () => {
68+
it.skipIf(noAuth).concurrent('gets performance data from SuperTrend strategy', async () => {
6469
const SuperTrend = new chart.Study(indicators.SuperTrend);
6570

6671
let QTY = 10;
@@ -109,7 +114,7 @@ describe('Indicators', () => {
109114
SuperTrend.remove();
110115
}, 10000);
111116

112-
it.concurrent('gets data from MarketCipher B study', async () => {
117+
it.skipIf(noAuth).concurrent('gets data from MarketCipher B study', async () => {
113118
const CipherB = new chart.Study(indicators.CipherB);
114119

115120
const lastResult: any = await new Promise((resolve) => {
@@ -132,12 +137,12 @@ describe('Indicators', () => {
132137
CipherB.remove();
133138
});
134139

135-
it('removes chart', () => {
140+
it.skipIf(noAuth)('removes chart', () => {
136141
console.log('Closing the chart...');
137142
chart.delete();
138143
});
139144

140-
it('removes client', async () => {
145+
it.skipIf(noAuth)('removes client', async () => {
141146
console.log('Closing the client...');
142147
await client.end();
143148
});

0 commit comments

Comments
 (0)