mirror of
https://github.com/iptv-org/epg
synced 2025-12-17 19:06:58 -05:00
added jest.mock('axios'), so axios is mecked with fake responses
This commit is contained in:
@@ -7,6 +7,10 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
|
jest.mock('axios')
|
||||||
|
|
||||||
const date = dayjs.utc('2022-12-02', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2022-12-02', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
site_id: 'RTPM',
|
site_id: 'RTPM',
|
||||||
@@ -39,9 +43,13 @@ it('can generate valid request method', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', async () => {
|
||||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||||
let results = parser({ content }).map(p => {
|
|
||||||
|
axios.post.mockResolvedValue({ data: {} })
|
||||||
|
|
||||||
|
let results = await parser({ content })
|
||||||
|
results = results.map(p => {
|
||||||
p.start = p.start.toJSON()
|
p.start = p.start.toJSON()
|
||||||
p.stop = p.stop.toJSON()
|
p.stop = p.stop.toJSON()
|
||||||
return p
|
return p
|
||||||
@@ -54,7 +62,7 @@ it('can parse response', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
it('can handle empty guide', async () => {
|
||||||
const result = parser({ content: '', channel, date })
|
const result = await parser({ content: '', channel, date })
|
||||||
expect(result).toMatchObject([])
|
expect(result).toMatchObject([])
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user