const { parser, url } = require('./pbsguam.org.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-25', 'YYYY-MM-DD').startOf('d') const channel = { site_id: '#', xmltv_id: 'KGTF.us' } it('can generate valid url', () => { expect(url).toBe('https://pbsguam.org/calendar/') }) it('can parse response', () => { const content = `
` const result = parser({ date, content }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() return p }) expect(result).toMatchObject([ { start: '2021-11-25T08:30:00.000Z', stop: '2021-11-25T09:00:00.000Z', title: 'Xavier Riddle and the Secret Museum' } ]) }) it('can handle empty guide', () => { const result = parser({ date, channel, content: ' ' }) expect(result).toMatchObject([]) })