Update tivu.tv.test.js

This commit is contained in:
Aleksandr Statciuk 2022-10-08 20:15:00 +03:00
parent 96890a9676
commit dfa8beab06

View file

@ -11,21 +11,23 @@ dayjs.extend(utc)
const axios = require('axios') const axios = require('axios')
jest.mock('axios') jest.mock('axios')
const date = dayjs.utc('2022-10-04', 'YYYY-MM-DD').startOf('d')
const channel = { const channel = {
site_id: '62', site_id: '62',
xmltv_id: 'Rai1HD.it' xmltv_id: 'Rai1HD.it'
} }
it('can generate valid url for today', () => { it('can generate valid url for today', () => {
const date = dayjs.utc().startOf('d')
expect(url({ date })).toBe('https://www.tivu.tv/epg_ajax_sat.aspx?d=0') expect(url({ date })).toBe('https://www.tivu.tv/epg_ajax_sat.aspx?d=0')
}) })
it('can generate valid url for tomorrow', () => { it('can generate valid url for tomorrow', () => {
expect(url({ date: date.add(1, 'd') })).toBe('https://www.tivu.tv/epg_ajax_sat.aspx?d=1') const date = dayjs.utc().startOf('d').add(1, 'd')
expect(url({ date })).toBe('https://www.tivu.tv/epg_ajax_sat.aspx?d=1')
}) })
it('can parse response', () => { it('can parse response', () => {
const date = dayjs.utc('2022-10-04', 'YYYY-MM-DD').startOf('d')
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
let results = parser({ content, channel, date }).map(p => { let results = parser({ content, channel, date }).map(p => {
@ -48,6 +50,7 @@ it('can parse response', () => {
}) })
it('can handle empty guide', () => { it('can handle empty guide', () => {
const date = dayjs.utc('2022-10-04', 'YYYY-MM-DD').startOf('d')
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html')) const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
const result = parser({ content, channel, date }) const result = parser({ content, channel, date })
expect(result).toMatchObject([]) expect(result).toMatchObject([])