@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
22import type { GridApiResponse } from "./tvlistings.js" ;
33import {
44 buildChannelsXml ,
5- buildProgrammesXml ,
5+ buildProgramsXml ,
66 buildXmltv ,
77 escapeXml ,
88 formatDate ,
@@ -57,7 +57,9 @@ describe("buildXmltv", () => {
5757 it ( "should generate valid XML structure" , ( ) => {
5858 const result = buildXmltv ( mockData ) ;
5959 expect ( result ) . toContain ( '<?xml version="1.0" encoding="UTF-8"?>' ) ;
60- expect ( result ) . toContain ( '<tv generator-info-name="zap2it-grid">' ) ;
60+ expect ( result ) . toContain (
61+ '<tv generator-info-name="jef/zap2xml" generator-info-url="https://github.com/jef/zap2xml">' ,
62+ ) ;
6163 expect ( result ) . toContain ( "</tv>" ) ;
6264 } ) ;
6365
@@ -85,14 +87,16 @@ describe("buildXmltv", () => {
8587
8688 it ( "should include rating information" , ( ) => {
8789 const result = buildXmltv ( mockData ) ;
88- expect ( result ) . toContain ( "<rating><value>TV-PG</value></rating>" ) ;
90+ expect ( result ) . toContain (
91+ '<rating system="MPAA"><value>TV-PG</value></rating>' ,
92+ ) ;
8993 } ) ;
9094
9195 it ( "should include categories from flags and tags" , ( ) => {
9296 const result = buildXmltv ( mockData ) ;
93- expect ( result ) . toContain ( "<category>New</category >" ) ;
94- expect ( result ) . toContain ( "<category>Stereo</category>" ) ;
95- expect ( result ) . toContain ( "<category>CC</category>" ) ;
97+ expect ( result ) . toContain ( "<new / >" ) ;
98+ expect ( result ) . toContain ( '<audio type="stereo" />' ) ;
99+ expect ( result ) . toContain ( '<audio type="cc" />' ) ;
96100 } ) ;
97101
98102 it ( "should include episode information" , ( ) => {
@@ -108,7 +112,9 @@ describe("buildXmltv", () => {
108112 const emptyData : GridApiResponse = { channels : [ ] } ;
109113 const result = buildXmltv ( emptyData ) ;
110114 expect ( result ) . toContain ( '<?xml version="1.0" encoding="UTF-8"?>' ) ;
111- expect ( result ) . toContain ( '<tv generator-info-name="zap2it-grid">' ) ;
115+ expect ( result ) . toContain (
116+ '<tv generator-info-name="jef/zap2xml" generator-info-url="https://github.com/jef/zap2xml">' ,
117+ ) ;
112118 expect ( result ) . toContain ( "</tv>" ) ;
113119 expect ( result ) . not . toContain ( "<channel" ) ;
114120 expect ( result ) . not . toContain ( "<programme" ) ;
@@ -252,9 +258,9 @@ describe("buildChannelsXml", () => {
252258 } ) ;
253259} ) ;
254260
255- describe ( "buildProgrammesXml " , ( ) => {
261+ describe ( "buildProgramsXml " , ( ) => {
256262 it ( "should build programme XML correctly" , ( ) => {
257- const result = buildProgrammesXml ( mockData ) ;
263+ const result = buildProgramsXml ( mockData ) ;
258264 expect ( result ) . toContain (
259265 '<programme start="20250718190000 +0000" stop="20250718200000 +0000" channel="19629">' ,
260266 ) ;
@@ -263,16 +269,20 @@ describe("buildProgrammesXml", () => {
263269 expect ( result ) . toContain (
264270 "<desc>BIA performs; comic Zarna Garg; lifestyle contributor Lori Bergamotto; ABC News chief medical correspondent Dr. Tara Narula.</desc>" ,
265271 ) ;
266- expect ( result ) . toContain ( "<rating><value>TV-PG</value></rating>" ) ;
267- expect ( result ) . toContain ( "<category>New</category>" ) ;
268- expect ( result ) . toContain ( "<category>Stereo</category>" ) ;
269- expect ( result ) . toContain ( "<category>CC</category>" ) ;
272+ expect ( result ) . toContain (
273+ '<rating system="MPAA"><value>TV-PG</value></rating>' ,
274+ ) ;
275+ expect ( result ) . toContain ( "<new />" ) ;
276+ expect ( result ) . toContain ( '<audio type="stereo" />' ) ;
277+ expect ( result ) . toContain ( '<audio type="cc" />' ) ;
270278 expect ( result ) . toContain ( '<episode-num system="season">5</episode-num>' ) ;
271279 expect ( result ) . toContain ( '<episode-num system="episode">217</episode-num>' ) ;
272280 expect ( result ) . toContain (
273281 '<episode-num system="series">SH05918266</episode-num>' ,
274282 ) ;
275- expect ( result ) . toContain ( '<icon src="p30687311_b_v13_aa" />' ) ;
283+ expect ( result ) . toContain (
284+ '<icon src="https://zap2it.tmsimg.com/assets/p30687311_b_v13_aa.jpg" />' ,
285+ ) ;
276286 } ) ;
277287
278288 it ( "should handle programmes without optional fields" , ( ) => {
@@ -318,7 +328,7 @@ describe("buildProgrammesXml", () => {
318328 } ,
319329 ] ,
320330 } ;
321- const result = buildProgrammesXml ( minimalProgramme ) ;
331+ const result = buildProgramsXml ( minimalProgramme ) ;
322332 expect ( result ) . toContain (
323333 '<programme start="20250718190000 +0000" stop="20250718193000 +0000" channel="123">' ,
324334 ) ;
0 commit comments