From 2535942b5c66ea8a4911df94b405169f4131a1f0 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sat, 11 Jan 2025 17:35:55 +0300 Subject: [PATCH] Create epg.112114.xyz.test.js --- sites/epg.112114.xyz/epg.112114.xyz.test.js | 42 +++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 sites/epg.112114.xyz/epg.112114.xyz.test.js diff --git a/sites/epg.112114.xyz/epg.112114.xyz.test.js b/sites/epg.112114.xyz/epg.112114.xyz.test.js new file mode 100644 index 00000000..ea6647c8 --- /dev/null +++ b/sites/epg.112114.xyz/epg.112114.xyz.test.js @@ -0,0 +1,42 @@ +const { parser, url } = require('./epg.112114.xyz.config.js') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const timezone = require('dayjs/plugin/timezone') +const fs = require('fs') +const path = require('path') + +dayjs.extend(utc) +dayjs.extend(timezone) + +const date = dayjs.utc('2025-01-11', 'YYYY-MM-DD').startOf('d') +const channel = { site_id: 'BTV文艺', xmltv_id: 'BRTVArtsChannel.cn', lang: 'zh' } + +it('can generate valid url', () => { + expect(url).toBe('https://epg.112114.xyz/pp.xml') +}) + +it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml')) + const results = parser({ date, content, channel }) + + expect(results.length).toBe(28) + expect(results[0]).toMatchObject({ + start: '2025-01-11T00:07:00.000Z', + stop: '2025-01-11T00:24:00.000Z', + title: '每日文艺播报' + }) + expect(results[27]).toMatchObject({ + start: '2025-01-11T15:16:00.000Z', + stop: '2025-01-11T15:59:00.000Z', + title: '笑动剧场' + }) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: '' + }) + expect(result).toMatchObject([]) +})