Update i.mjh.nz.test.js

This commit is contained in:
freearhey 2023-06-23 15:06:30 +03:00
parent 4ca21c9ca7
commit ee8870af2e

View file

@ -2,36 +2,41 @@
// npx epg-grabber --config=sites/i.mjh.nz/i.mjh.nz.config.js --channels=sites/i.mjh.nz/i.mjh.nz_plex.channels.xml --output=guide.xml // npx epg-grabber --config=sites/i.mjh.nz/i.mjh.nz.config.js --channels=sites/i.mjh.nz/i.mjh.nz_plex.channels.xml --output=guide.xml
const { parser, url } = require('./i.mjh.nz.config.js') const { parser, url } = require('./i.mjh.nz.config.js')
const fs = require('fs')
const path = require('path')
const dayjs = require('dayjs') const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc') const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat') const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat) dayjs.extend(customParseFormat)
dayjs.extend(utc) dayjs.extend(utc)
const date = dayjs.utc('2022-05-03', 'YYYY-MM-DD').startOf('d') const date = dayjs.utc('2023-06-23', 'YYYY-MM-DD').startOf('d')
const channel = { const channel = {
site_id: 'PlutoTV/us#51c75f7bb6f26ba1cd00002f', site_id: 'Plex/all#5e20b730f2f8d5003d739db7-5eea605674085f0040ddc7a6',
xmltv_id: 'LittleStarsUniverse.us', xmltv_id: 'DarkMatterTV.us',
lang: 'en' lang: 'en'
} }
it('can generate valid url', () => { it('can generate valid url', () => {
expect(url({ channel })).toBe( expect(url({ channel })).toBe(
'https://raw.githubusercontent.com/matthuisman/i.mjh.nz/master/PlutoTV/us.xml' 'https://raw.githubusercontent.com/matthuisman/i.mjh.nz/master/Plex/all.xml'
) )
}) })
it('can parse response', () => { it('can parse response', () => {
const content = `<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE tv SYSTEM "xmltv.dtd"><tv generator-info-name="www.matthuisman.nz"> <channel id="51c75f7bb6f26ba1cd00002f"> <display-name>Little Stars Universe</display-name> <icon src="https://images.pluto.tv/channels/51c75f7bb6f26ba1cd00002f/colorLogoPNG.png"/> </channel> <programme channel="51c75f7bb6f26ba1cd00002f" start="20220503104922 +0000" stop="20220503112122 +0000"> <title>Barney and Friends</title> <desc>Baby Bop forgets to say "please" and "thank you". Riff shares his dream of becoming an inventor.</desc> <category>Children &amp; Family</category> </programme><programme channel="51c75f7bb6f26ba1cd00002f" start="20220504104922 +0000" stop="20220504112122 +0000"> <title>Barney and Friends</title> <desc>Baby Bop forgets to say "please" and "thank you". Riff shares his dream of becoming an inventor.</desc> <category>Children &amp; Family</category> </programme></tv>` const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml'))
const results = parser({ content, channel, date }) const results = parser({ content, channel, date })
expect(results.length).toBe(11)
expect(results[0]).toMatchObject({ expect(results[0]).toMatchObject({
start: '2022-05-03T10:49:22.000Z', start: '2023-06-23T07:14:32.000Z',
stop: '2022-05-03T11:21:22.000Z', stop: '2023-06-23T09:09:36.000Z',
title: 'Barney and Friends', title: 'Killers Within',
date: ['20180101'],
description: description:
'Baby Bop forgets to say "please" and "thank you". Riff shares his dream of becoming an inventor.', '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.',
categories: ['Children &amp; Family'] icon: ['https://provider-static.plex.tv/epg/images/thumbnails/darkmatter-tv-fallback.jpg'],
categories: ['Movie']
}) })
}) })