Skip to content

Commit 0456c5b

Browse files
Add categories testing
Add testing for categories tag with provided filter information in API response
1 parent 6e6fa26 commit 0456c5b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/xmltv.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const mockData: GridApiResponse = {
2424
endTime: "2025-07-18T20:00:00Z",
2525
thumbnail: "p30687311_b_v13_aa",
2626
channelNo: "4.1",
27-
filter: ["filter-news"],
27+
filter: ["filter-news", "filter-sports"],
2828
seriesId: "SH05918266",
2929
rating: "TV-PG",
3030
flag: ["New"],
@@ -85,6 +85,12 @@ describe("buildXmltv", () => {
8585
);
8686
});
8787

88+
it("should include category information", () => {
89+
const result = buildXmltv(mockData);
90+
expect(result).toContain('<category lang="en">news</category>');
91+
expect(result).toContain('<category lang="en">sports</category>');
92+
});
93+
8894
it("should include rating information", () => {
8995
const result = buildXmltv(mockData);
9096
expect(result).toContain(
@@ -173,7 +179,7 @@ describe("buildXmltv", () => {
173179
expect(result).not.toContain("<sub-title>");
174180
expect(result).not.toContain("<desc>");
175181
expect(result).not.toContain("<rating>");
176-
expect(result).not.toContain("<category>");
182+
expect(result).not.toContain('<category lang="en">');
177183
expect(result).not.toContain("<episode-num");
178184
expect(result).not.toContain("<icon");
179185
});
@@ -269,6 +275,8 @@ describe("buildProgramsXml", () => {
269275
expect(result).toContain(
270276
"<desc>BIA performs; comic Zarna Garg; lifestyle contributor Lori Bergamotto; ABC News chief medical correspondent Dr. Tara Narula.</desc>",
271277
);
278+
expect(result).toContain('<category lang="en">news</category>');
279+
expect(result).toContain('<category lang="en">sports</category>');
272280
expect(result).toContain(
273281
'<rating system="MPAA"><value>TV-PG</value></rating>',
274282
);
@@ -336,7 +344,7 @@ describe("buildProgramsXml", () => {
336344
expect(result).not.toContain("<sub-title>");
337345
expect(result).not.toContain("<desc>");
338346
expect(result).not.toContain("<rating>");
339-
expect(result).not.toContain("<category>");
347+
expect(result).not.toContain('<category lange="en">');
340348
expect(result).not.toContain("<episode-num");
341349
expect(result).not.toContain("<icon");
342350
});

0 commit comments

Comments
 (0)