-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
266 lines (196 loc) · 6.75 KB
/
test.js
File metadata and controls
266 lines (196 loc) · 6.75 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
// Frontend Tests
// Cosmetics class
const Cosmetics = require('./Cosmetics');
describe('Cosmetics', () => {
//initialize instance
let cosmetics;
beforeEach(() => {
// created sample thems of new instances
const themes = ['theme1', 'theme2', 'theme3'];
cosmetics = new Cosmetics(themes);
});
describe('Change_Theme', () => {
// Test cases for changeTheme method
test('Should change the theme of cosmetics', () => {
// Test implementation...
});
test('Should not change the theme if the provided theme does not exist', () => {
// Test implementation...
});
});
describe('Earn_Points', () => {
// Test cases for earnPoints method
test('Should add earned points to the user profile', () => {
// Test implementation...
});
});
describe('Spend_Points', () => {
// Test cases for spendPoints method
test('Should deduct spent points from the user profile', () => {
// Test implementation...
});
test('Should not allow spending points if the user does not have enough points', () => {
// Test implementation...
});
});
});
// DynamicTextGen
// Import module
const DynamicTextGen = require('./Dynamic_Text_Gen');
describe('DynamicTextGen_Module', () => {
// Initialize instance
let dynamicTextGen;
beforeEach(() => {
// Created sample patterns
const Patterns = ['Pattern 1', 'Pattern 2', 'Pattern 3'];
dynamicTextGen = new DynamicTextGen(Patterns);
});
describe('generateText_Method', () => {
// Test case
test('Should generate dynamic text based on predefined patterns', () => {
// Generate text/ verify text to be string
const generatedText = dynamicTextGen.generateText();
expect(typeof generatedText).toBe('string');
});
});
});
// Gamemodes
const GameModes = require('./Game_Modes');
describe('GameModes', () => {
let gameModes;
beforeEach(() => {
// Initialize GameModes instance
gameModes = new GameModes();
});
describe('Single_Player_Mode', () => {
test('Should start a single-player game session', () => {
const gameSession = gameModes.singlePlayerMode();
// Test implementation...
});
});
describe('Multiplayer_Mode', () => {
test('Should start a multiplayer game session', () => {
const gameSession = gameModes.multiplayerMode();
// Test implementation...
});
});
describe('Practice_Mode', () => {
test('Should start a practice game session', () => {
const gameSession = gameModes.practiceMode();
// Test implementation...
});
});
describe('Dynamic_Race_Mode', () => {
test('Should start a dynamic race game session', () => {
const gameSession = gameModes.dynamicRace();
// Test implementation...
});
});
describe('Robot_Opponent_Mode', () => {
test('Should start a game session against a robot opponent', () => {
const gameSession = gameModes.robotOpponentMode();
// Test implementation...
});
});
});
// KeyboardAnimation
const KeyboardAnimation = require('./KeyboardAnimation');
describe('KeyboardAnimation', () => {
let keyboardAnimation;
beforeEach(() => {
// Initialize KeyboardAnimation instance with a sample key press
keyboardAnimation = new KeyboardAnimation('A');
});
describe('Display_Animation', () => {
// Test Case
test('Should display keyboard animation for the pressed key', () => {
// Test implementation...
});
});
});
// Leaderboard
const Leaderboard = require('./Leaderboard');
describe('Leaderboard', () => {
let leaderboard;
beforeEach(() => {
// Initialize Leaderboard instance with sample player ranks
leaderboard = new Leaderboard([10, 20, 30, 40, 50]);
});
describe('Update_Leaderboard', () => {
// Test case
test('Should update the leaderboard with a new player\'s rank', () => {
// Test implementation...
});
});
describe('View_Top_Players', () => {
//Test Case
test('Should retrieve the top players from the leaderboard', () => {
const topPlayers = leaderboard.viewTopPlayers();
// Test implementation...
});
});
});
// UserAuthentication
const UserAuthentication = require('./UserAuthentication');
describe('UserAuthentication', () => {
let userAuth;
beforeEach(() => {
// Initialize UserAuthentication instance with a sample backend service URL
userAuth = new UserAuthentication('Website');
});
describe('Login', () => {
test('should log in a user', () => {
const username = 'testuser';
const password = 'password';
// Test implementation...
});
});
describe('Register', () => {
test('should register a new user', () => {
const username = 'newuser';
const email = 'newuser@example.com';
const password = 'password';
// Test implementation...
});
});
describe('Continue_as_Guest', () => {
test('should allow the user to continue as a guest', () => {
// Test implementation...
});
});
});
// Game Session
const gameSession = require('./gameSession');
describe('Game_Session', () => {
beforeEach(() => {
// Reset currentText and userInput before each test
gameSession.currentText = "";
gameSession.userInput = "";
});
describe('Start_Game', () => {
test('should initialize variables and display the system', () => {
// Test implementation...
});
});
describe('End_Game', () => {
test('should perform close cases for the system', () => {
// Test implementation...
});
});
describe('Calculate_WPM', () => {
test('should calculate words per minute (WPM)', () => {
// Set up currentText and userInput for testing...
gameSession.currentText = "I can sort of type really fast.";
gameSession.userInput = "I can type really fast.";
// Test implementation...
});
});
describe('Calculate_Accuracy', () => {
test('should calculate accuracy percentage', () => {
// Set up currentText and userInput for testing...
gameSession.currentText = "I can sort of type really fast.";
gameSession.userInput = "I can type really fast.";
// Test implementation...
});
});
});