返回 slidev
timesplit.test.ts
根目录 / packages / parser / src / timesplit / timesplit.test.ts
1 import { describe, expect, it } from 'vitest'
2 import { parseTimesplits } from './timesplit'
3
4 describe('parseTimesplits', () => {
5 it('should parse timestamp into seconds', () => {
6 expect(parseTimesplits([
7 { no: 1, timesplit: '+10s' },
8 { no: 5, timesplit: '10:10' },
9 { no: 3, timesplit: '15m' },
10 { no: 7, timesplit: '1h10m30s' },
11 ])).toMatchInlineSnapshot(`
12 [
13 {
14 "noEnd": 1,
15 "noStart": 0,
16 "timestampEnd": 10,
17 "timestampStart": 0,
18 "title": "[start]",
19 },
20 {
21 "noEnd": 5,
22 "noStart": 1,
23 "timestampEnd": 610,
24 "timestampStart": 10,
25 },
26 {
27 "noEnd": 3,
28 "noStart": 5,
29 "timestampEnd": 900,
30 "timestampStart": 610,
31 },
32 {
33 "noEnd": 7,
34 "noStart": 3,
35 "timestampEnd": 4230,
36 "timestampStart": 900,
37 },
38 {
39 "noEnd": 7,
40 "noStart": 7,
41 "timestampEnd": 4230,
42 "timestampStart": 4230,
43 },
44 ]
45 `)
46 })
47 })
48
48 lines TYPESCRIPT