@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
2
2
import type { GridApiResponse } from "./tvlistings.js" ;
3
3
import {
4
4
buildChannelsXml ,
5
- buildProgrammesXml ,
5
+ buildProgramsXml ,
6
6
buildXmltv ,
7
7
escapeXml ,
8
8
formatDate ,
@@ -57,7 +57,9 @@ describe("buildXmltv", () => {
57
57
it ( "should generate valid XML structure" , ( ) => {
58
58
const result = buildXmltv ( mockData ) ;
59
59
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
+ ) ;
61
63
expect ( result ) . toContain ( "</tv>" ) ;
62
64
} ) ;
63
65
@@ -85,14 +87,16 @@ describe("buildXmltv", () => {
85
87
86
88
it ( "should include rating information" , ( ) => {
87
89
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
+ ) ;
89
93
} ) ;
90
94
91
95
it ( "should include categories from flags and tags" , ( ) => {
92
96
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" />' ) ;
96
100
} ) ;
97
101
98
102
it ( "should include episode information" , ( ) => {
@@ -108,7 +112,9 @@ describe("buildXmltv", () => {
108
112
const emptyData : GridApiResponse = { channels : [ ] } ;
109
113
const result = buildXmltv ( emptyData ) ;
110
114
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
+ ) ;
112
118
expect ( result ) . toContain ( "</tv>" ) ;
113
119
expect ( result ) . not . toContain ( "<channel" ) ;
114
120
expect ( result ) . not . toContain ( "<programme" ) ;
@@ -252,9 +258,9 @@ describe("buildChannelsXml", () => {
252
258
} ) ;
253
259
} ) ;
254
260
255
- describe ( "buildProgrammesXml " , ( ) => {
261
+ describe ( "buildProgramsXml " , ( ) => {
256
262
it ( "should build programme XML correctly" , ( ) => {
257
- const result = buildProgrammesXml ( mockData ) ;
263
+ const result = buildProgramsXml ( mockData ) ;
258
264
expect ( result ) . toContain (
259
265
'<programme start="20250718190000 +0000" stop="20250718200000 +0000" channel="19629">' ,
260
266
) ;
@@ -263,16 +269,20 @@ describe("buildProgrammesXml", () => {
263
269
expect ( result ) . toContain (
264
270
"<desc>BIA performs; comic Zarna Garg; lifestyle contributor Lori Bergamotto; ABC News chief medical correspondent Dr. Tara Narula.</desc>" ,
265
271
) ;
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" />' ) ;
270
278
expect ( result ) . toContain ( '<episode-num system="season">5</episode-num>' ) ;
271
279
expect ( result ) . toContain ( '<episode-num system="episode">217</episode-num>' ) ;
272
280
expect ( result ) . toContain (
273
281
'<episode-num system="series">SH05918266</episode-num>' ,
274
282
) ;
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
+ ) ;
276
286
} ) ;
277
287
278
288
it ( "should handle programmes without optional fields" , ( ) => {
@@ -318,7 +328,7 @@ describe("buildProgrammesXml", () => {
318
328
} ,
319
329
] ,
320
330
} ;
321
- const result = buildProgrammesXml ( minimalProgramme ) ;
331
+ const result = buildProgramsXml ( minimalProgramme ) ;
322
332
expect ( result ) . toContain (
323
333
'<programme start="20250718190000 +0000" stop="20250718193000 +0000" channel="123">' ,
324
334
) ;
0 commit comments