11import { describe , it , expect } from 'vitest' ;
22import TradingView from '../main' ;
33
4+ const token = < string > process . env . SESSION ;
5+ const signature = < string > process . env . SIGNATURE ;
6+
47describe ( '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