Update utils.test.js

This commit is contained in:
Aleksandr Statciuk 2021-10-31 00:59:57 +03:00
parent f658009ae2
commit 65d63fce0e
1 changed files with 23 additions and 0 deletions

View File

@ -73,6 +73,29 @@ it('can convert object to xmltv string', () => {
)
})
it('can convert object to xmltv string with multiple categories', () => {
const file = fs.readFileSync('./tests/input/example.com.channels.xml', { encoding: 'utf-8' })
const parsed = utils.parseChannels(file)
const channels = parsed.channels
const programs = [
{
title: 'Program 1',
description: 'Description for Program 1',
start: '2021-03-19 06:00:00 +0000',
stop: '2021-03-19 06:30:00 +0000',
category: ['Test1', 'Test2'],
icon: 'https://example.com/images/Program1.png?x=шеллы&sid=777',
channel: '1TV.com',
lang: 'it'
}
]
const config = { site: 'example.com' }
const output = utils.convertToXMLTV({ config, channels, programs })
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=шеллы&amp;sid=777"/></programme>\r\n</tv>'
)
})
it('can escape string', () => {
const string = 'Música тест dun. &<>"\'\r\n'
expect(utils.escapeString(string)).toBe('Música тест dun. &amp;&lt;&gt;&quot;&apos;')