Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Download web_app/src/lib/timestamp.test.ts from CommunityOne/open-navigator: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/spaces/CommunityOne/open-navigator/resolve/main/web_app/src/lib/timestamp.test.ts
- Command line
-
hf download hf://spaces/CommunityOne/open-navigator/web_app/src/lib/timestamp.test.ts
-
curl -L -o timestamp.test.ts https://huggingface.co/spaces/CommunityOne/open-navigator/resolve/main/web_app/src/lib/timestamp.test.ts
1.33 kB
| import { describe, expect, it } from 'vitest' | |
| import { formatTimestamp, meetingMomentPath, parseTimestamp } from './timestamp' | |
| describe('parseTimestamp', () => { | |
| it.each([ | |
| ['754', 754], | |
| ['754.9', 754], | |
| ['12m34s', 754], | |
| ['1h2m3s', 3723], | |
| ['2h', 7200], | |
| ['45s', 45], | |
| ['12:34', 754], | |
| ['1:02:03', 3723], | |
| ['0', 0], | |
| ])('reads %s as %d seconds', (value, seconds) => { | |
| expect(parseTimestamp(value)).toBe(seconds) | |
| }) | |
| it.each([null, '', ' ', 'abc', '-5', '1:2:3:4', '12:75', 'm', '1h2x'])('rejects %s', (value) => { | |
| expect(parseTimestamp(value as string | null)).toBeNull() | |
| }) | |
| }) | |
| describe('formatTimestamp', () => { | |
| it.each([ | |
| [0, '0:00'], | |
| [45, '0:45'], | |
| [754, '12:34'], | |
| [3723, '1:02:03'], | |
| [754.9, '12:34'], | |
| [-3, '0:00'], | |
| ])('formats %d as %s', (seconds, text) => { | |
| expect(formatTimestamp(seconds)).toBe(text) | |
| }) | |
| }) | |
| describe('meetingMomentPath', () => { | |
| it('links to the second, rounded down', () => { | |
| expect(meetingMomentPath('abc123', 754.9)).toBe('/meetings/abc123?t=754') | |
| }) | |
| it('links to the meeting when the time is unknown', () => { | |
| expect(meetingMomentPath('abc123', null)).toBe('/meetings/abc123') | |
| }) | |
| it('encodes the meeting id', () => { | |
| expect(meetingMomentPath('a b/c', 5)).toBe('/meetings/a%20b%2Fc?t=5') | |
| }) | |
| }) | |