From b85abb28850d69a6510b0f4ba6a36ffd8316c0fb Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:41:57 +0300 Subject: [PATCH] Create thesportplus.com.test.js --- .../thesportplus.com/thesportplus.com.test.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 sites/thesportplus.com/thesportplus.com.test.js diff --git a/sites/thesportplus.com/thesportplus.com.test.js b/sites/thesportplus.com/thesportplus.com.test.js new file mode 100644 index 00000000..ed431fda --- /dev/null +++ b/sites/thesportplus.com/thesportplus.com.test.js @@ -0,0 +1,50 @@ +const { parser, url } = require('./thesportplus.com.config.js') +const fs = require('fs') +const path = require('path') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const customParseFormat = require('dayjs/plugin/customParseFormat') +dayjs.extend(customParseFormat) +dayjs.extend(utc) + +const date = dayjs.utc('2025-01-19', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'usa', + xmltv_id: 'SportPlusUSA.us' +} + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe('https://www.thesportplus.com/schedule_usa.php?d=2025-01-19') +}) + +it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) + const results = parser({ content, date, channel }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(results.length).toBe(13) + expect(results[0]).toMatchObject({ + start: '2025-01-19T06:00:00.000Z', + stop: '2025-01-19T08:00:00.000Z', + title: 'ASTERAS vs ATROMITOS', + description: 'Super League Season 24-25 MD 4' + }) + expect(results[12]).toMatchObject({ + start: '2025-01-20T04:00:00.000Z', + stop: '2025-01-20T05:00:00.000Z', + title: 'SPORTSHOW', + description: 'Super League' + }) +}) + +it('can handle empty guide', () => { + const results = parser({ + date, + channel, + content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html')) + }) + expect(results).toMatchObject([]) +})