import Channel from '../src/Channel' import Program from '../src/Program' import xmltv from '../src/xmltv' jest.useFakeTimers('modern').setSystemTime(new Date('2022-05-05')) const channels = [ new Channel({ xmltv_id: '1TV.co', name: '1 TV', logo: 'https://example.com/logos/1TV.png', site: 'example.com' }), new Channel({ xmltv_id: '2TV.co', name: '2 TV', site: 'example.com', lang: 'es' }) ] it('can generate xmltv', () => { const programs = [ new Program( { title: 'Program 1', sub_title: 'Sub-title & 1', description: 'Description for Program 1', url: 'http://example.com/title.html', start: '2021-03-19T06:00:00.000Z', stop: '2021-03-19T06:30:00.000Z', category: 'Test', date: '2022-05-06', season: 9, episode: 239, icon: 'https://example.com/images/Program1.png?x=шеллы&sid=777', rating: { system: 'MPAA', value: 'P&G', icon: 'http://example.com/pg_symbol.png' }, director: [ { value: 'Director 1', url: { value: 'http://example.com/director1.html', system: 'TestSystem' }, image: [ 'https://example.com/image1.jpg', { value: 'https://example.com/image2.jpg', type: 'person', size: '2', system: 'TestSystem', orient: 'P' } ] }, 'Director 2' ], actor: ['Actor 1', 'Actor 2'], writer: 'Writer 1' }, channels[0] ), new Program( { title: 'Program 2', start: '2021-03-19T06:00:00.000Z', stop: '2021-03-19T06:30:00.000Z' }, channels[1] ) ] const output = xmltv.generate({ channels, programs }) expect(output).toBe( '\r\n1 TVhttps://example.com\r\n2 TVhttps://example.com\r\nProgram 1Sub-title & 1Description for Program 1Director 1http://example.com/director1.htmlhttps://example.com/image1.jpghttps://example.com/image2.jpgDirector 2Actor 1Actor 2Writer 120220506Testhttp://example.com/title.html8.238.0/1S09E239P&G\r\nProgram 2\r\n' ) })