-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
80 lines (74 loc) · 1.73 KB
/
test.js
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
// Test script 1 - prints numbers every second
const test1 = () => {
let i = 0;
setInterval(() => {
console.log(`Counter: ${i++}`);
}, 1000);
};
// Test script 2 - prints random numbers every 2 seconds
const test2 = () => {
setInterval(() => {
console.log(`Random: ${Math.random()}`);
}, 2000);
};
// Test script 3 - prints timestamp every 1.5 seconds
const test3 = () => {
setInterval(() => {
console.log(`Time: ${new Date().toISOString()}`);
}, 1500);
};
// Test script 4 - simulates a database startup
const test4 = () => {
console.log("Database starting...");
setTimeout(() => {
console.log("Database ready!");
setInterval(() => {
console.log("Database: Processing queries...");
}, 2000);
}, 3000);
};
// Test script 5 - simulates an API server that depends on database
const test5 = () => {
console.log("API server starting...");
setTimeout(() => {
console.log("API server ready on port 3000!");
setInterval(() => {
console.log("API: Processing requests...");
}, 1500);
}, 2000);
};
// Test script 6 - simulates a frontend that depends on API
const test6 = () => {
console.log("Frontend starting...");
setTimeout(() => {
console.log("Frontend dev server ready!");
setInterval(() => {
console.log("Frontend: Compiling changes...");
}, 3000);
}, 1500);
};
// Run the one specified by argument
const script = process.argv[2];
switch (script) {
case "test1":
test1();
break;
case "test2":
test2();
break;
case "test3":
test3();
break;
case "test4":
test4();
break;
case "test5":
test5();
break;
case "test6":
test6();
break;
default:
console.error("Please specify test1-6");
process.exit(1);
}