Skip to content

Commit e33d709

Browse files
committed
Better tests + Add "Authenticated" test
1 parent 0f70936 commit e33d709

12 files changed

Lines changed: 110 additions & 23 deletions

.github/workflows/node.js.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ jobs:
2626
run: npm ci
2727
- name: Run tests
2828
run: npm test
29+
env:
30+
SESSION: ${{ secrets.TW_SESSION }}

test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,21 @@ function success() {
4747
}
4848

4949
console.info('§90§30§104 ==== ALL TESTS DONE ==== §0\n');
50+
51+
let errored = false;
52+
5053
Object.keys(TESTS).forEach((t) => {
5154
let color = '2';
5255
if (TESTS[t].warnings) color = '3';
53-
if (TESTS[t].errors) color = '1';
56+
if (TESTS[t].errors) {
57+
color = '1';
58+
errored = true;
59+
}
5460

5561
console.info(`§90§30§10${color} ${t} §0 §91E§0: ${TESTS[t].errors}§0 §93W§0: ${TESTS[t].warnings}`);
56-
// console.info(` - §91 Errors:§0 ${TESTS[t].errors}`);
57-
// console.info(` - §93 Warnings:§0 ${TESTS[t].warnings}`);
5862
});
5963

60-
process.exit(0);
64+
process.exit(errored ? 1 : 0);
6165
})();
6266

6367
setTimeout(() => {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module.exports = async (log, success, warn, err, cb) => {
1111

1212
if (markets.length < 10 || indicators.length < 10) {
1313
err('Not enough results');
14-
throw new Error('Not enough results');
1514
}
1615

1716
cb();
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = (log, success, warn, err, cb) => {
55

66
client.onError((...error) => {
77
err('Client error', ...error);
8-
throw new Error('Client error');
98
});
109

1110
const quoteSession = new client.Session.Quote({
@@ -38,7 +37,6 @@ module.exports = (log, success, warn, err, cb) => {
3837
keys.forEach((k) => {
3938
if (!rsKeys.includes(k)) {
4039
err(`Missing '${k}' key in`, rsKeys);
41-
throw new Error('Missing key');
4240
}
4341
});
4442

@@ -49,6 +47,5 @@ module.exports = (log, success, warn, err, cb) => {
4947

5048
BTC.onError((...error) => {
5149
err('BTCEUR ERROR:', error);
52-
throw new Error('Missing key');
5350
});
5451
};
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = async (log, success, warn, err, cb) => {
55

66
client.onError((...error) => {
77
err('Client error', error);
8-
throw new Error('Client error');
98
});
109

1110
const chart = new client.Session.Chart();
@@ -16,7 +15,6 @@ module.exports = async (log, success, warn, err, cb) => {
1615

1716
chart.onError((...error) => {
1817
err('Chart error', error);
19-
throw new Error('Chart error');
2018
});
2119

2220
chart.onSymbolLoaded(() => { // When the symbol is successfully loaded
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = async (log, success, warn, err, cb) => {
55

66
client.onError((...error) => {
77
err('Client error', error);
8-
throw new Error('Client error');
98
});
109

1110
const chart = new client.Session.Chart();
@@ -15,7 +14,6 @@ module.exports = async (log, success, warn, err, cb) => {
1514

1615
chart.onError((...error) => {
1716
err('Chart error', error);
18-
throw new Error('Chart error');
1917
});
2018

2119
TradingView.getIndicator('STD;Supertrend%Strategy').then((indicator) => {
@@ -31,7 +29,6 @@ module.exports = async (log, success, warn, err, cb) => {
3129

3230
SuperTrend.onError((...error) => {
3331
err('SuperTrend error', error[0]);
34-
throw new Error('SuperTrend error');
3532
});
3633

3734
let QTY = 10;
@@ -81,7 +78,6 @@ module.exports = async (log, success, warn, err, cb) => {
8178

8279
CipherB.onError((...error) => {
8380
err('MarketCipher B error:', error[0]);
84-
throw new Error('MarketCipher B error');
8581
});
8682

8783
CipherB.onUpdate(() => {
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = async (log, success, warn, err, cb) => {
55

66
client.onError((...error) => {
77
err('Client error', error);
8-
throw new Error('Client error');
98
});
109

1110
const chart = new client.Session.Chart();
@@ -15,7 +14,6 @@ module.exports = async (log, success, warn, err, cb) => {
1514

1615
chart.onError((...error) => {
1716
err('Chart error', error);
18-
throw new Error('Chart error');
1917
});
2018

2119
const volumeProfile = new TradingView.BuiltInIndicator('VbPFixed@tv-basicstudies-139!');
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = async (log, success, warn, err, cb) => {
55

66
client.onError((...error) => {
77
err('Client error', error);
8-
throw new Error('Client error');
98
});
109

1110
const chart = new client.Session.Chart();
@@ -17,7 +16,6 @@ module.exports = async (log, success, warn, err, cb) => {
1716

1817
chart.onError((...error) => {
1918
err('Chart error', error);
20-
throw new Error('Chart error');
2119
});
2220

2321
let interval = NaN;
@@ -43,7 +41,7 @@ module.exports = async (log, success, warn, err, cb) => {
4341
if (Number.isNaN(interval) && times.length >= 2) interval = intrval;
4442

4543
if (!Number.isNaN(interval) && interval !== intrval) {
46-
throw new Error(`Wrong interval: ${intrval} (should be ${interval})`);
44+
err(`Wrong interval: ${intrval} (should be ${interval})`);
4745
}
4846

4947
log('Next ->', times[0]);
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = async (log, success, warn, err, cb) => {
55

66
client.onError((...error) => {
77
err('Client error', error);
8-
throw new Error('Client error');
98
});
109

1110
const chart = new client.Session.Chart();
@@ -17,7 +16,6 @@ module.exports = async (log, success, warn, err, cb) => {
1716

1817
chart.onError((...error) => {
1918
err('Chart error', error);
20-
throw new Error('Chart error');
2119
});
2220

2321
let finished = false;
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ module.exports = async (log, success, warn, err, cb) => {
55

66
client.onError((...error) => {
77
err('Client error', error);
8-
throw new Error('Client error');
98
});
109

1110
const chart = new client.Session.Chart();
1211

1312
chart.onError((...error) => {
1413
err('Chart error', error);
15-
throw new Error('Chart error');
1614
});
1715

1816
/* (0s) Heikin Ashi chart */

0 commit comments

Comments
 (0)