-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTestUtils.js
More file actions
107 lines (99 loc) · 3.3 KB
/
Copy pathTestUtils.js
File metadata and controls
107 lines (99 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Constant imports
import LOG_TYPE from '../constants/TestConstants';
// Local variables
let testing = true;
let testingUserInteraction = false;
let api = true;
let connection = true;
let auth = true;
let log = true;
let redux = true;
let intercept = true;
let screen = true;
let button_click = true;
let swipe = true;
let page_view = true;
let FgRed = '\x1b[31m';
let FgGreen = '\x1b[32m';
let FgYellow = '\x1b[33m';
let FgCyan = '\x1b[36m';
let FgMagenta = '\u001b[35m';
let BgBlue = '\u001b[44;1m';
let BgMagenta = '\u001b[45;1m';
let BgCyan = '\u001b[46;1m';
let BgBlack = '\u001b[40m';
// Local functions
const screenLoaded = (type = LOG_TYPE.SCREEN, msg = '', from = '') => {
if (testing) {
if (screen && type == LOG_TYPE.SCREEN) {
console.log(`${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
}
};
const good = (type = LOG_TYPE.LOG, msg = '', from = '') => {
if (testing) {
if (api && type == LOG_TYPE.API) {
console.log(`Successful ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (connection && type == LOG_TYPE.CON) {
console.log(`Successful ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (log && type == LOG_TYPE.LOG) {
console.log(`Successful ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (intercept && type == LOG_TYPE.INTERCEPT) {
console.log(`Successful ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (auth && type == LOG_TYPE.AUTH) {
console.log(`Successful ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (redux && type == LOG_TYPE.REDUX) {
console.log(`Successful ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
}
};
const warn = (type = LOG_TYPE.LOG, msg = '', from = '') => {
if (testing) {
if (api && type == LOG_TYPE.API) {
console.log(`Warn ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (connection && type == LOG_TYPE.CON) {
console.log(`Warn ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (log && type == LOG_TYPE.LOG) {
console.log(`Warn ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (intercept && type == LOG_TYPE.INTERCEPT) {
console.log(`Warn ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (auth && type == LOG_TYPE.AUTH) {
console.log(`Warn ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (redux && type == LOG_TYPE.REDUX) {
console.log(`Warn ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
}
};
const bad = (type = LOG_TYPE.LOG, msg = '', from = '') => {
if (testing) {
if (api && type == LOG_TYPE.API) {
console.log(`! FAILED ! ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (connection && type == LOG_TYPE.CON) {
console.log(`! FAILED ! ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (log && type == LOG_TYPE.LOG) {
console.log(`! FAILED ! ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (intercept && type == LOG_TYPE.INTERCEPT) {
console.log(`! FAILED ! ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (auth && type == LOG_TYPE.AUTH) {
console.log(`! FAILED ! ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
if (redux && type == LOG_TYPE.REDUX) {
console.log(`! FAILED ! ${type}`, `${JSON.stringify(msg)}`, `${from}`);
}
}
};
export {good, warn, bad, screenLoaded};