const { parser, url } = require('./vidio.com.config.js') 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('2021-11-24', 'YYYY-MM-DD').startOf('d') const channel = { site_id: '7464', xmltv_id: 'AjwaTV.id' } it('can generate valid url', () => { expect(url({ channel })).toBe('https://www.vidio.com/live/7464/schedules') }) it('can parse response', () => { const content = '
' const result = parser({ content, date }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() return p }) expect(result).toMatchObject([ { start: '2021-11-23T17:30:00.000Z', stop: '2021-11-23T18:30:00.000Z', title: '30 Hari 30 Juz' }, { start: '2021-11-23T18:30:00.000Z', stop: '2021-11-23T21:00:00.000Z', title: 'Makkah Live' }, { start: '2021-11-24T15:30:00.000Z', stop: '2021-11-24T17:30:00.000Z', title: 'FTV Islami' } ]) }) it('can handle empty guide', () => { const result = parser({ date, channel, content: '' }) expect(result).toMatchObject([]) })