Update utils.test.js
This commit is contained in:
parent
f1d02c9d62
commit
4672fb7cc2
|
@ -28,9 +28,8 @@ it('can load valid config.js', () => {
|
||||||
|
|
||||||
it('can parse valid channels.xml', () => {
|
it('can parse valid channels.xml', () => {
|
||||||
const file = fs.readFileSync('./tests/input/example.com.channels.xml', { encoding: 'utf-8' })
|
const file = fs.readFileSync('./tests/input/example.com.channels.xml', { encoding: 'utf-8' })
|
||||||
const parsed = utils.parseChannels(file)
|
const channels = utils.parseChannels(file)
|
||||||
expect(parsed.site).toBe('example.com')
|
expect(channels).toEqual([
|
||||||
expect(parsed.channels).toEqual([
|
|
||||||
{
|
{
|
||||||
name: '1 TV',
|
name: '1 TV',
|
||||||
xmltv_id: '1TV.com',
|
xmltv_id: '1TV.com',
|
||||||
|
@ -52,8 +51,7 @@ it('can parse valid channels.xml', () => {
|
||||||
|
|
||||||
it('can convert object to xmltv string', () => {
|
it('can convert object to xmltv string', () => {
|
||||||
const file = fs.readFileSync('./tests/input/example.com.channels.xml', { encoding: 'utf-8' })
|
const file = fs.readFileSync('./tests/input/example.com.channels.xml', { encoding: 'utf-8' })
|
||||||
const parsed = utils.parseChannels(file)
|
const channels = utils.parseChannels(file)
|
||||||
const channels = parsed.channels
|
|
||||||
const programs = [
|
const programs = [
|
||||||
{
|
{
|
||||||
title: 'Program 1',
|
title: 'Program 1',
|
||||||
|
@ -66,8 +64,7 @@ it('can convert object to xmltv string', () => {
|
||||||
lang: 'it'
|
lang: 'it'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
const config = { site: 'example.com' }
|
const output = utils.convertToXMLTV({ channels, programs })
|
||||||
const output = utils.convertToXMLTV({ config, channels, programs })
|
|
||||||
expect(output).toBe(
|
expect(output).toBe(
|
||||||
'<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>\r\n<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.com"><title lang="it">Program 1</title><desc lang="it">Description for Program 1</desc><category lang="it">Test</category><icon src="https://example.com/images/Program1.png?x=шеллы&sid=777"/></programme>\r\n</tv>'
|
'<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>\r\n<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.com"><title lang="it">Program 1</title><desc lang="it">Description for Program 1</desc><category lang="it">Test</category><icon src="https://example.com/images/Program1.png?x=шеллы&sid=777"/></programme>\r\n</tv>'
|
||||||
)
|
)
|
||||||
|
@ -102,8 +99,7 @@ it('can convert object to xmltv string without categories', () => {
|
||||||
|
|
||||||
it('can convert object to xmltv string with multiple categories', () => {
|
it('can convert object to xmltv string with multiple categories', () => {
|
||||||
const file = fs.readFileSync('./tests/input/example.com.channels.xml', { encoding: 'utf-8' })
|
const file = fs.readFileSync('./tests/input/example.com.channels.xml', { encoding: 'utf-8' })
|
||||||
const parsed = utils.parseChannels(file)
|
const channels = utils.parseChannels(file)
|
||||||
const channels = parsed.channels
|
|
||||||
const programs = [
|
const programs = [
|
||||||
{
|
{
|
||||||
title: 'Program 1',
|
title: 'Program 1',
|
||||||
|
@ -116,8 +112,7 @@ it('can convert object to xmltv string with multiple categories', () => {
|
||||||
lang: 'it'
|
lang: 'it'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
const config = { site: 'example.com' }
|
const output = utils.convertToXMLTV({ channels, programs })
|
||||||
const output = utils.convertToXMLTV({ config, channels, programs })
|
|
||||||
expect(output).toBe(
|
expect(output).toBe(
|
||||||
'<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>\r\n<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.com"><title lang="it">Program 1</title><desc lang="it">Description for Program 1</desc><category lang="it">Test1</category><category lang="it">Test2</category><icon src="https://example.com/images/Program1.png?x=шеллы&sid=777"/></programme>\r\n</tv>'
|
'<?xml version="1.0" encoding="UTF-8" ?><tv>\r\n<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>\r\n<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>\r\n<programme start="20210319060000 +0000" stop="20210319063000 +0000" channel="1TV.com"><title lang="it">Program 1</title><desc lang="it">Description for Program 1</desc><category lang="it">Test1</category><category lang="it">Test2</category><icon src="https://example.com/images/Program1.png?x=шеллы&sid=777"/></programme>\r\n</tv>'
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue