Update pluto.tv.test.js

This commit is contained in:
Newbiect 2025-01-01 11:05:50 -05:00 committed by GitHub
parent 6fb40b5c07
commit 5f2219b672
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,33 +1,33 @@
const config = require('./pluto.tv.config.js'); const config = require('./pluto.tv.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')
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('2024-12-28', 'YYYY-MM-DD').startOf('d'); const date = dayjs.utc('2024-12-28', 'YYYY-MM-DD').startOf('d')
const channel = { const channel = {
site_id: '5ee92e72fb286e0007285fec', site_id: '5ee92e72fb286e0007285fec',
xmltv_id: 'Naruto' xmltv_id: 'Naruto'
}; }
it('can generate valid url', () => { it('can generate valid url', () => {
const url = config.url({ date, channel }); const url = config.url({ date, channel })
expect(url).toBe( expect(url).toBe(
'https://api.pluto.tv/v2/channels/5ee92e72fb286e0007285fec?start=2024-12-27T12:00:00.000Z&stop=2024-12-31T11:59:59.999Z' 'https://api.pluto.tv/v2/channels/5ee92e72fb286e0007285fec?start=2024-12-27T12:00:00.000Z&stop=2024-12-31T11:59:59.999Z'
); )
}); })
it('can parse response', () => { it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8'); const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8')
const results = config.parser({ content }).map(p => { const results = config.parser({ content }).map(p => {
p.start = dayjs(p.start).toJSON(); p.start = dayjs(p.start).toJSON()
p.stop = dayjs(p.stop).toJSON(); p.stop = dayjs(p.stop).toJSON()
return p; return p
}); })
expect(results[0]).toMatchObject({ expect(results[0]).toMatchObject({
start: '2024-12-28T00:21:00.000Z', start: '2024-12-28T00:21:00.000Z',
@ -45,12 +45,12 @@ it('can parse response', () => {
rating: 'TV-14', rating: 'TV-14',
date: '2004-04-21T00:00:00.000Z', date: '2004-04-21T00:00:00.000Z',
icon: 'https://images.pluto.tv/series/5e73b850e40c9f001a0a9fb4/tile.jpg?fill=blur&fit=fill&fm=jpg&h=660&q=75&w=660' icon: 'https://images.pluto.tv/series/5e73b850e40c9f001a0a9fb4/tile.jpg?fill=blur&fit=fill&fm=jpg&h=660&q=75&w=660'
}); })
}); })
it('can handle empty guide', () => { it('can handle empty guide', () => {
const results = config.parser({ const results = config.parser({
content: '[]' content: '[]'
}); })
expect(results).toMatchObject([]); expect(results).toMatchObject([])
}); })