const { parser, url } = require('./hoy.tv.config.js') const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') dayjs.extend(utc) jest.mock('axios') const date = dayjs.utc('2024-09-13', 'YYYY-MM-DD').startOf('d') const channel = { site_id: '76', xmltv_id: 'HOYIBC.hk', lang: 'zh' } const content = ` 2024-09-13 11:30:00 2024-09-13 12:30:00 [PG] false false 2024-09-27 11:30:00 0 0 http://tv.fantv.hk/images/thumbnail_1920_1080_fantv.jpg EQ00135 46 點講都係一家人 http://tv.fantv.hk/images/nosuchthumbnail.jpg 點講都係一家人 0 EQ00135 點講都係一家人 Episode 46 1 20240913 1130 0001 3704000 2024-09-13 12:30:00 2024-09-13 13:30:00 false false 2024-09-27 12:30:00 0 0 http://tv.fantv.hk/images/thumbnail_1920_1080_fantv.jpg ED00311 0 麝香之路 Ep. 2 .The Secret of disappeared kingdom.shows the mysterious disappearance of the ancient Tibetan kingdom which gained world http://tv.fantv.hk/images/nosuchthumbnail.jpg 麝香之路 0 ED00311 麝香之路 2024-09-13 1 20240913 1230 0001 3704000 ` it('can generate valid url', () => { expect(url({ channel, date })).toBe('https://epg-file.hoy.tv/hoy/OTT7620240913.xml') }) it('can parse response', () => { const result = parser({ content, channel, date }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() return p }) expect(result).toMatchObject([ { start: '2024-09-13T03:30:00.000Z', stop: '2024-09-13T04:30:00.000Z', title: '點講都係一家人[PG]', sub_title: '第46集' }, { start: '2024-09-13T04:30:00.000Z', stop: '2024-09-13T05:30:00.000Z', title: '麝香之路', description: 'Ep. 2 .The Secret of disappeared kingdom.shows the mysterious disappearance of the ancient Tibetan kingdom which gained world' } ]) })