Files
epg/sites/i.mjh.nz/i.mjh.nz.test.js

51 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-06-23 13:50:30 +03:00
// npm run channels:parse -- --config=./sites/i.mjh.nz/i.mjh.nz.config.js --output=./sites/i.mjh.nz/i.mjh.nz_pluto.channels.xml --set=path:PlutoTV/all
2023-10-02 06:35:33 +03:00
// npm run grab -- --site=i.mjh.nz
2022-05-03 16:51:34 +03:00
const { parser, url } = require('./i.mjh.nz.config.js')
2023-06-23 15:06:30 +03:00
const fs = require('fs')
const path = require('path')
2022-05-03 16:51:34 +03:00
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
dayjs.extend(utc)
2023-06-23 15:06:30 +03:00
const date = dayjs.utc('2023-06-23', 'YYYY-MM-DD').startOf('d')
2022-05-03 16:51:34 +03:00
const channel = {
2023-06-23 15:06:30 +03:00
site_id: 'Plex/all#5e20b730f2f8d5003d739db7-5eea605674085f0040ddc7a6',
xmltv_id: 'DarkMatterTV.us',
2022-05-03 16:51:34 +03:00
lang: 'en'
}
it('can generate valid url', () => {
expect(url({ channel })).toBe(
2023-06-23 15:06:30 +03:00
'https://raw.githubusercontent.com/matthuisman/i.mjh.nz/master/Plex/all.xml'
2022-05-03 16:51:34 +03:00
)
})
it('can parse response', () => {
2023-06-23 15:06:30 +03:00
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml'))
2022-11-20 17:44:22 +03:00
const results = parser({ content, channel, date })
2022-05-03 16:51:34 +03:00
2023-06-23 15:06:30 +03:00
expect(results.length).toBe(11)
2022-11-20 17:44:22 +03:00
expect(results[0]).toMatchObject({
2023-06-23 15:06:30 +03:00
start: '2023-06-23T07:14:32.000Z',
stop: '2023-06-23T09:09:36.000Z',
title: 'Killers Within',
date: ['20180101'],
2022-11-21 17:24:08 +03:00
description:
2023-06-23 15:06:30 +03:00
'With her son being held captive by a criminal gang, police officer Amanda Doyle, together with her ex-husband and three unlikely allies, takes part in a desperate plot to hold a wealthy banker and his family to ransom. But this is no ordinary family.',
icon: ['https://provider-static.plex.tv/epg/images/thumbnails/darkmatter-tv-fallback.jpg'],
categories: ['Movie']
2022-11-20 17:44:22 +03:00
})
2022-05-03 16:51:34 +03:00
})
it('can handle empty guide', () => {
const result = parser({
2023-10-02 06:35:33 +03:00
content: '404: Not Found',
2022-05-03 16:51:34 +03:00
channel,
date
})
expect(result).toMatchObject([])
})