mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Update pickx.be.test.js
This commit is contained in:
parent
fbaae670d9
commit
6ee49862f6
1 changed files with 34 additions and 20 deletions
|
@ -1,35 +1,49 @@
|
||||||
jest.mock('./pickx.be.config.js', () => {
|
const { parser, url, request } = require('./pickx.be.config.js')
|
||||||
const originalModule = jest.requireActual('./pickx.be.config.js')
|
const axios = require('axios')
|
||||||
return {
|
|
||||||
...originalModule,
|
|
||||||
fetchApiVersion: jest.fn(() => Promise.resolve())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const { parser, url, request, setApiVersion } = require('./pickx.be.config.js')
|
|
||||||
|
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
jest.mock('axios')
|
||||||
|
|
||||||
|
axios.get.mockImplementation((url, data) => {
|
||||||
|
if (url === 'https://www.pickx.be/nl/televisie/tv-gids') {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: fs.readFileSync(path.resolve(__dirname, '__data__/hash.html'), 'utf8')
|
||||||
|
})
|
||||||
|
} else if (
|
||||||
|
url ===
|
||||||
|
'https://www.pickx.be/api/s-375ce5e452cf964b4158545d9ddf26cc97d6411f0998a2fa7ed5922c88d5bdc4' &&
|
||||||
|
JSON.stringify(data) ===
|
||||||
|
JSON.stringify({
|
||||||
|
headers: {
|
||||||
|
Origin: 'https://www.pickx.be',
|
||||||
|
Referer: 'https://www.pickx.be/'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
return Promise.resolve({
|
||||||
|
status: 200,
|
||||||
|
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/version.json')))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: ''
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const date = dayjs.utc('2023-12-13').startOf('d')
|
const date = dayjs.utc('2023-12-13').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
lang: 'fr',
|
lang: 'fr',
|
||||||
site_id: 'UID0118',
|
site_id: 'UID0118'
|
||||||
xmltv_id: 'Vedia.be'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
setApiVersion('mockedApiVersion')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('can generate valid url', async () => {
|
it('can generate valid url', async () => {
|
||||||
const generatedUrl = await url({ channel, date })
|
expect(await url({ channel, date })).toBe(
|
||||||
expect(generatedUrl).toBe(
|
'https://px-epg.azureedge.net/airings/21738594888692v.4.2/2023-12-13/channel/UID0118?timezone=Europe%2FBrussels'
|
||||||
'https://px-epg.azureedge.net/airings/mockedApiVersion/2023-12-13/channel/UID0118?timezone=Europe%2FBrussels'
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue