This commit is contained in:
1 parent
74df7780fd
commit
d266a8258d
9 files changed
+32
-15
No files matched your search
@@ -7,18 +7,23 @@ const { parseChannelName, normalizeText } = require('../src/channel-name');
|
||||
const sample =
|
||||
'View BE| DAZN 03 [Standard de Liège - SK Beveren | Jupiler Pro League (nl) (2026-11-06 19:25:00)]';
|
||||
|
||||
test('parses the DAZN sample', () => {
|
||||
const parsed = parseChannelName(sample, { timezone: 'Europe/Brussels' });
|
||||
test('parses the DAZN sample with UTC source timestamps', () => {
|
||||
const parsed = parseChannelName(sample, { timezone: 'UTC' });
|
||||
assert.equal(parsed.title, 'Standard de Liège - SK Beveren');
|
||||
assert.equal(parsed.league, 'Jupiler Pro League');
|
||||
assert.equal(parsed.language, 'nl');
|
||||
assert.equal(parsed.startAt.toISOString(), '2026-11-06T19:25:00.000Z');
|
||||
});
|
||||
|
||||
test('can parse the same timestamp in another source timezone', () => {
|
||||
const parsed = parseChannelName(sample, { timezone: 'Europe/Brussels' });
|
||||
assert.equal(parsed.startAt.toISOString(), '2026-11-06T18:25:00.000Z');
|
||||
});
|
||||
|
||||
test('parses a French stream', () => {
|
||||
const parsed = parseChannelName(
|
||||
'View BE| DAZN 03 [Standard de Liège - SK Beveren | Jupiler Pro League (fr) (2026-11-06 19:25:00)]',
|
||||
{ timezone: 'Europe/Brussels' }
|
||||
{ timezone: 'UTC' }
|
||||
);
|
||||
assert.equal(parsed.language, 'fr');
|
||||
});
|
||||
@@ -26,14 +31,14 @@ test('parses a French stream', () => {
|
||||
test('allows a missing language code', () => {
|
||||
const parsed = parseChannelName(
|
||||
'DAZN 03 [Standard de Liège - SK Beveren | Jupiler Pro League (2026-11-06 19:25:00)]',
|
||||
{ timezone: 'Europe/Brussels' }
|
||||
{ timezone: 'UTC' }
|
||||
);
|
||||
assert.equal(parsed.language, null);
|
||||
});
|
||||
|
||||
test('returns null for unparseable names', () => {
|
||||
assert.equal(parseChannelName('DAZN 03', { timezone: 'Europe/Brussels' }), null);
|
||||
assert.equal(parseChannelName('', { timezone: 'Europe/Brussels' }), null);
|
||||
assert.equal(parseChannelName('DAZN 03', { timezone: 'UTC' }), null);
|
||||
assert.equal(parseChannelName('', { timezone: 'UTC' }), null);
|
||||
});
|
||||
|
||||
test('normalizes diacritics and whitespace', () => {
|
||||
|
||||
@@ -4,7 +4,7 @@ const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { buildEvents, compareEvents, isEligible } = require('../src/events');
|
||||
|
||||
const timezone = 'Europe/Brussels';
|
||||
const timezone = 'UTC';
|
||||
|
||||
function stream(id, name) {
|
||||
return { stream_id: id, name };
|
||||
|
||||
Reference in new issue
Block a user