Skip to content

Commit 491a0cb

Browse files
[CI] Format code
1 parent 25fdd14 commit 491a0cb

1 file changed

Lines changed: 108 additions & 94 deletions

File tree

Lines changed: 108 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,239 +1,253 @@
1-
import { describe, expect, test, xtest } from "@jest/globals";
2-
import { SplitSecondStopwatch } from "./split-second-stopwatch";
1+
import { describe, expect, test, xtest } from '@jest/globals';
2+
import { SplitSecondStopwatch } from './split-second-stopwatch';
33

4-
describe("SplitSecondStopwatch", () => {
5-
test("new stopwatch starts in ready state", () => {
4+
describe('SplitSecondStopwatch', () => {
5+
test('new stopwatch starts in ready state', () => {
66
const stopwatch = new SplitSecondStopwatch();
7-
expect(stopwatch.state).toBe("ready");
7+
expect(stopwatch.state).toBe('ready');
88
});
99

1010
xtest("new stopwatch's current lap has no elapsed time", () => {
1111
const stopwatch = new SplitSecondStopwatch();
12-
expect(stopwatch.currentLap).toBe("00:00:00");
12+
expect(stopwatch.currentLap).toBe('00:00:00');
1313
});
1414

1515
xtest("new stopwatch's total has no elapsed time", () => {
1616
const stopwatch = new SplitSecondStopwatch();
17-
expect(stopwatch.total).toBe("00:00:00");
17+
expect(stopwatch.total).toBe('00:00:00');
1818
});
1919

20-
xtest("new stopwatch does not have previous laps", () => {
20+
xtest('new stopwatch does not have previous laps', () => {
2121
const stopwatch = new SplitSecondStopwatch();
2222
expect(stopwatch.previousLaps).toEqual([]);
2323
});
2424

25-
xtest("start from ready state changes state to running", () => {
25+
xtest('start from ready state changes state to running', () => {
2626
const stopwatch = new SplitSecondStopwatch();
2727
stopwatch.start();
28-
expect(stopwatch.state).toBe("running");
28+
expect(stopwatch.state).toBe('running');
2929
});
3030

31-
xtest("start does not change previous laps", () => {
31+
xtest('start does not change previous laps', () => {
3232
const stopwatch = new SplitSecondStopwatch();
3333
stopwatch.start();
3434
expect(stopwatch.previousLaps).toEqual([]);
3535
});
3636

37-
xtest("start initiates time tracking for current lap", () => {
37+
xtest('start initiates time tracking for current lap', () => {
3838
const stopwatch = new SplitSecondStopwatch();
3939
stopwatch.start();
40-
stopwatch.advanceTime("00:00:05");
41-
expect(stopwatch.currentLap).toBe("00:00:05");
40+
stopwatch.advanceTime('00:00:05');
41+
expect(stopwatch.currentLap).toBe('00:00:05');
4242
});
4343

44-
xtest("start initiates time tracking for total", () => {
44+
xtest('start initiates time tracking for total', () => {
4545
const stopwatch = new SplitSecondStopwatch();
4646
stopwatch.start();
47-
stopwatch.advanceTime("00:00:23");
48-
expect(stopwatch.total).toBe("00:00:23");
47+
stopwatch.advanceTime('00:00:23');
48+
expect(stopwatch.total).toBe('00:00:23');
4949
});
5050

51-
xtest("start cannot be called from running state", () => {
51+
xtest('start cannot be called from running state', () => {
5252
const stopwatch = new SplitSecondStopwatch();
5353
stopwatch.start();
54-
expect(() => stopwatch.start()).toThrow("cannot start an already running stopwatch");
54+
expect(() => stopwatch.start()).toThrow(
55+
'cannot start an already running stopwatch',
56+
);
5557
});
5658

57-
xtest("stop from running state changes state to stopped", () => {
59+
xtest('stop from running state changes state to stopped', () => {
5860
const stopwatch = new SplitSecondStopwatch();
5961
stopwatch.start();
6062
stopwatch.stop();
61-
expect(stopwatch.state).toBe("stopped");
63+
expect(stopwatch.state).toBe('stopped');
6264
});
6365

64-
xtest("stop pauses time tracking for current lap", () => {
66+
xtest('stop pauses time tracking for current lap', () => {
6567
const stopwatch = new SplitSecondStopwatch();
6668
stopwatch.start();
67-
stopwatch.advanceTime("00:00:05");
69+
stopwatch.advanceTime('00:00:05');
6870
stopwatch.stop();
69-
stopwatch.advanceTime("00:00:08");
70-
expect(stopwatch.currentLap).toBe("00:00:05");
71+
stopwatch.advanceTime('00:00:08');
72+
expect(stopwatch.currentLap).toBe('00:00:05');
7173
});
7274

73-
xtest("stop pauses time tracking for total", () => {
75+
xtest('stop pauses time tracking for total', () => {
7476
const stopwatch = new SplitSecondStopwatch();
7577
stopwatch.start();
76-
stopwatch.advanceTime("00:00:13");
78+
stopwatch.advanceTime('00:00:13');
7779
stopwatch.stop();
78-
stopwatch.advanceTime("00:00:44");
79-
expect(stopwatch.total).toBe("00:00:13");
80+
stopwatch.advanceTime('00:00:44');
81+
expect(stopwatch.total).toBe('00:00:13');
8082
});
8183

82-
xtest("stop cannot be called from ready state", () => {
84+
xtest('stop cannot be called from ready state', () => {
8385
const stopwatch = new SplitSecondStopwatch();
84-
expect(() => stopwatch.stop()).toThrow("cannot stop a stopwatch that is not running");
86+
expect(() => stopwatch.stop()).toThrow(
87+
'cannot stop a stopwatch that is not running',
88+
);
8589
});
8690

87-
xtest("stop cannot be called from stopped state", () => {
91+
xtest('stop cannot be called from stopped state', () => {
8892
const stopwatch = new SplitSecondStopwatch();
8993
stopwatch.start();
9094
stopwatch.stop();
91-
expect(() => stopwatch.stop()).toThrow("cannot stop a stopwatch that is not running");
95+
expect(() => stopwatch.stop()).toThrow(
96+
'cannot stop a stopwatch that is not running',
97+
);
9298
});
9399

94-
xtest("start from stopped state changes state to running", () => {
100+
xtest('start from stopped state changes state to running', () => {
95101
const stopwatch = new SplitSecondStopwatch();
96102
stopwatch.start();
97103
stopwatch.stop();
98104
stopwatch.start();
99-
expect(stopwatch.state).toBe("running");
105+
expect(stopwatch.state).toBe('running');
100106
});
101107

102-
xtest("start from stopped state resumes time tracking for current lap", () => {
108+
xtest('start from stopped state resumes time tracking for current lap', () => {
103109
const stopwatch = new SplitSecondStopwatch();
104110
stopwatch.start();
105-
stopwatch.advanceTime("00:01:20");
111+
stopwatch.advanceTime('00:01:20');
106112
stopwatch.stop();
107-
stopwatch.advanceTime("00:00:20");
113+
stopwatch.advanceTime('00:00:20');
108114
stopwatch.start();
109-
stopwatch.advanceTime("00:00:08");
110-
expect(stopwatch.currentLap).toBe("00:01:28");
115+
stopwatch.advanceTime('00:00:08');
116+
expect(stopwatch.currentLap).toBe('00:01:28');
111117
});
112118

113-
xtest("start from stopped state resumes time tracking for total", () => {
119+
xtest('start from stopped state resumes time tracking for total', () => {
114120
const stopwatch = new SplitSecondStopwatch();
115121
stopwatch.start();
116-
stopwatch.advanceTime("00:00:23");
122+
stopwatch.advanceTime('00:00:23');
117123
stopwatch.stop();
118-
stopwatch.advanceTime("00:00:44");
124+
stopwatch.advanceTime('00:00:44');
119125
stopwatch.start();
120-
stopwatch.advanceTime("00:00:09");
121-
expect(stopwatch.total).toBe("00:00:32");
126+
stopwatch.advanceTime('00:00:09');
127+
expect(stopwatch.total).toBe('00:00:32');
122128
});
123129

124-
xtest("lap adds current lap to previous laps", () => {
130+
xtest('lap adds current lap to previous laps', () => {
125131
const stopwatch = new SplitSecondStopwatch();
126132
stopwatch.start();
127-
stopwatch.advanceTime("00:01:38");
133+
stopwatch.advanceTime('00:01:38');
128134
stopwatch.lap();
129-
expect(stopwatch.previousLaps).toEqual(["00:01:38"]);
130-
stopwatch.advanceTime("00:00:44");
135+
expect(stopwatch.previousLaps).toEqual(['00:01:38']);
136+
stopwatch.advanceTime('00:00:44');
131137
stopwatch.lap();
132-
expect(stopwatch.previousLaps).toEqual(["00:01:38", "00:00:44"]);
138+
expect(stopwatch.previousLaps).toEqual(['00:01:38', '00:00:44']);
133139
});
134140

135-
xtest("lap resets current lap and resumes time tracking", () => {
141+
xtest('lap resets current lap and resumes time tracking', () => {
136142
const stopwatch = new SplitSecondStopwatch();
137143
stopwatch.start();
138-
stopwatch.advanceTime("00:08:22");
144+
stopwatch.advanceTime('00:08:22');
139145
stopwatch.lap();
140-
expect(stopwatch.currentLap).toBe("00:00:00");
141-
stopwatch.advanceTime("00:00:15");
142-
expect(stopwatch.currentLap).toBe("00:00:15");
146+
expect(stopwatch.currentLap).toBe('00:00:00');
147+
stopwatch.advanceTime('00:00:15');
148+
expect(stopwatch.currentLap).toBe('00:00:15');
143149
});
144150

145-
xtest("lap continues time tracking for total", () => {
151+
xtest('lap continues time tracking for total', () => {
146152
const stopwatch = new SplitSecondStopwatch();
147153
stopwatch.start();
148-
stopwatch.advanceTime("00:00:22");
154+
stopwatch.advanceTime('00:00:22');
149155
stopwatch.lap();
150-
stopwatch.advanceTime("00:00:33");
151-
expect(stopwatch.total).toBe("00:00:55");
156+
stopwatch.advanceTime('00:00:33');
157+
expect(stopwatch.total).toBe('00:00:55');
152158
});
153159

154-
xtest("lap cannot be called from ready state", () => {
160+
xtest('lap cannot be called from ready state', () => {
155161
const stopwatch = new SplitSecondStopwatch();
156-
expect(() => stopwatch.lap()).toThrow("cannot lap a stopwatch that is not running");
162+
expect(() => stopwatch.lap()).toThrow(
163+
'cannot lap a stopwatch that is not running',
164+
);
157165
});
158166

159-
xtest("lap cannot be called from stopped state", () => {
167+
xtest('lap cannot be called from stopped state', () => {
160168
const stopwatch = new SplitSecondStopwatch();
161169
stopwatch.start();
162170
stopwatch.stop();
163-
expect(() => stopwatch.lap()).toThrow("cannot lap a stopwatch that is not running");
171+
expect(() => stopwatch.lap()).toThrow(
172+
'cannot lap a stopwatch that is not running',
173+
);
164174
});
165175

166-
xtest("stop does not change previous laps", () => {
176+
xtest('stop does not change previous laps', () => {
167177
const stopwatch = new SplitSecondStopwatch();
168178
stopwatch.start();
169-
stopwatch.advanceTime("00:11:22");
179+
stopwatch.advanceTime('00:11:22');
170180
stopwatch.lap();
171-
expect(stopwatch.previousLaps).toEqual(["00:11:22"]);
181+
expect(stopwatch.previousLaps).toEqual(['00:11:22']);
172182
stopwatch.stop();
173-
expect(stopwatch.previousLaps).toEqual(["00:11:22"]);
183+
expect(stopwatch.previousLaps).toEqual(['00:11:22']);
174184
});
175185

176-
xtest("reset from stopped state changes state to ready", () => {
186+
xtest('reset from stopped state changes state to ready', () => {
177187
const stopwatch = new SplitSecondStopwatch();
178188
stopwatch.start();
179189
stopwatch.stop();
180190
stopwatch.reset();
181-
expect(stopwatch.state).toBe("ready");
191+
expect(stopwatch.state).toBe('ready');
182192
});
183193

184-
xtest("reset resets current lap", () => {
194+
xtest('reset resets current lap', () => {
185195
const stopwatch = new SplitSecondStopwatch();
186196
stopwatch.start();
187-
stopwatch.advanceTime("00:00:10");
197+
stopwatch.advanceTime('00:00:10');
188198
stopwatch.stop();
189199
stopwatch.reset();
190-
expect(stopwatch.currentLap).toBe("00:00:00");
200+
expect(stopwatch.currentLap).toBe('00:00:00');
191201
});
192202

193-
xtest("reset clears previous laps", () => {
203+
xtest('reset clears previous laps', () => {
194204
const stopwatch = new SplitSecondStopwatch();
195205
stopwatch.start();
196-
stopwatch.advanceTime("00:00:10");
206+
stopwatch.advanceTime('00:00:10');
197207
stopwatch.lap();
198-
stopwatch.advanceTime("00:00:20");
208+
stopwatch.advanceTime('00:00:20');
199209
stopwatch.lap();
200-
expect(stopwatch.previousLaps).toEqual(["00:00:10", "00:00:20"]);
210+
expect(stopwatch.previousLaps).toEqual(['00:00:10', '00:00:20']);
201211
stopwatch.stop();
202212
stopwatch.reset();
203213
expect(stopwatch.previousLaps).toEqual([]);
204214
});
205215

206-
xtest("reset cannot be called from ready state", () => {
216+
xtest('reset cannot be called from ready state', () => {
207217
const stopwatch = new SplitSecondStopwatch();
208-
expect(() => stopwatch.reset()).toThrow("cannot reset a stopwatch that is not stopped");
218+
expect(() => stopwatch.reset()).toThrow(
219+
'cannot reset a stopwatch that is not stopped',
220+
);
209221
});
210222

211-
xtest("reset cannot be called from running state", () => {
223+
xtest('reset cannot be called from running state', () => {
212224
const stopwatch = new SplitSecondStopwatch();
213225
stopwatch.start();
214-
expect(() => stopwatch.reset()).toThrow("cannot reset a stopwatch that is not stopped");
226+
expect(() => stopwatch.reset()).toThrow(
227+
'cannot reset a stopwatch that is not stopped',
228+
);
215229
});
216230

217-
xtest("supports very long laps", () => {
231+
xtest('supports very long laps', () => {
218232
const stopwatch = new SplitSecondStopwatch();
219233
stopwatch.start();
220-
stopwatch.advanceTime("01:23:45");
221-
expect(stopwatch.currentLap).toBe("01:23:45");
234+
stopwatch.advanceTime('01:23:45');
235+
expect(stopwatch.currentLap).toBe('01:23:45');
222236
stopwatch.lap();
223-
expect(stopwatch.previousLaps).toEqual(["01:23:45"]);
224-
stopwatch.advanceTime("04:01:40");
225-
expect(stopwatch.currentLap).toBe("04:01:40");
226-
expect(stopwatch.total).toBe("05:25:25");
237+
expect(stopwatch.previousLaps).toEqual(['01:23:45']);
238+
stopwatch.advanceTime('04:01:40');
239+
expect(stopwatch.currentLap).toBe('04:01:40');
240+
expect(stopwatch.total).toBe('05:25:25');
227241
stopwatch.lap();
228-
expect(stopwatch.previousLaps).toEqual(["01:23:45", "04:01:40"]);
229-
stopwatch.advanceTime("08:43:05");
230-
expect(stopwatch.currentLap).toBe("08:43:05");
231-
expect(stopwatch.total).toBe("14:08:30");
242+
expect(stopwatch.previousLaps).toEqual(['01:23:45', '04:01:40']);
243+
stopwatch.advanceTime('08:43:05');
244+
expect(stopwatch.currentLap).toBe('08:43:05');
245+
expect(stopwatch.total).toBe('14:08:30');
232246
stopwatch.lap();
233247
expect(stopwatch.previousLaps).toEqual([
234-
"01:23:45",
235-
"04:01:40",
236-
"08:43:05",
248+
'01:23:45',
249+
'04:01:40',
250+
'08:43:05',
237251
]);
238252
});
239253
});

0 commit comments

Comments
 (0)