mirror of
https://github.com/iptv-org/epg
synced 2026-05-10 19:37:00 -04:00
Change tokenk Axios wrapper to multifetch, config changes
This commit is contained in:
@@ -1,38 +1,31 @@
|
||||
const { parser, url } = require('./dsmart.com.tr.config.js')
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
const multifetch = require('../../scripts/core/multifetch')
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
const date = dayjs.utc('2025-01-13', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '5fe07f5dcfef0b1593275822',
|
||||
xmltv_id: 'Sinema1001.tr'
|
||||
}
|
||||
|
||||
axios.get.mockImplementation(url => {
|
||||
const result = {}
|
||||
const urls = {
|
||||
beforeEach(() => {
|
||||
multifetch.setMocks({
|
||||
'https://www.dsmart.com.tr/api/v1/public/epg/schedules?page=1&limit=10&day=2025-01-13':
|
||||
'content1.json',
|
||||
'https://www.dsmart.com.tr/api/v1/public/epg/schedules?page=2&limit=10&day=2025-01-13':
|
||||
'content2.json',
|
||||
}
|
||||
if (urls[url] !== undefined) {
|
||||
result.data = fs.readFileSync(path.join(__dirname, '__data__', urls[url])).toString()
|
||||
if (!urls[url].startsWith('content1')) {
|
||||
result.data = JSON.parse(result.data)
|
||||
}
|
||||
}
|
||||
}, __dirname + '/__data__')
|
||||
})
|
||||
|
||||
return Promise.resolve(result)
|
||||
afterEach(() => {
|
||||
multifetch.clearMocks()
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user