Skip to content

Commit

Permalink
fix(epg): check lower case, log error
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLantukh committed Jan 15, 2024
1 parent 43c487c commit be774d4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const CONTENT_TYPE = {
// Page with a list of channels
live: 'live',
// Separate channel page
liveChannel: 'liveChannel',
liveChannel: 'livechannel',
// Static page with markdown
page: 'page',
// Page with shelves list
Expand Down Expand Up @@ -75,6 +75,6 @@ export const DEFAULT_FEATURES = {
};

export const EPG_TYPE = {
JWP: 'JWP',
VIEW_NEXA: 'VIEW_NEXA',
jwp: 'jwp',
viewNexa: 'viewnexa',
} as const;
4 changes: 2 additions & 2 deletions src/modules/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ container.bind('INTEGRATION_TYPE').toDynamicValue((context) => {
});

// EPG services
container.bind(EpgService).to(JWEpgService).whenTargetNamed(EPG_TYPE.JWP);
container.bind(EpgService).to(ViewNexaEpgService).whenTargetNamed(EPG_TYPE.VIEW_NEXA);
container.bind(EpgService).to(JWEpgService).whenTargetNamed(EPG_TYPE.jwp);
container.bind(EpgService).to(ViewNexaEpgService).whenTargetNamed(EPG_TYPE.viewNexa);

// Cleeng integration
container.bind(CleengService).toSelf();
Expand Down
4 changes: 2 additions & 2 deletions src/services/epg/viewNexa.epg.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ describe('ViewNexaEpgService', () => {

test('fetchSchedule performs a request', async () => {
const mock = mockGet('/epg/viewNexaChannel.xml').willResolveOnce([]);
const data = await epgService.fetchSchedule({ ...livePlaylist.playlist[0], scheduleUrl: '/epg/viewNexaChannel.xml', scheduleType: EPG_TYPE.VIEW_NEXA });
const data = await epgService.fetchSchedule({ ...livePlaylist.playlist[0], scheduleUrl: '/epg/viewNexaChannel.xml', scheduleType: EPG_TYPE.viewNexa });

expect(mock).toHaveFetched();
expect(data).toEqual([]);
});

test('fetchSchedule parses xml content', async () => {
const mock = mockGet('/epg/viewNexaChannel.xml').willResolveOnce(viewNexaChannel);
const data = await epgService.fetchSchedule({ ...livePlaylist.playlist[0], scheduleUrl: '/epg/viewNexaChannel.xml', scheduleType: EPG_TYPE.VIEW_NEXA });
const data = await epgService.fetchSchedule({ ...livePlaylist.playlist[0], scheduleUrl: '/epg/viewNexaChannel.xml', scheduleType: EPG_TYPE.viewNexa });

expect(mock).toHaveFetched();
expect(data[0]).toEqual({
Expand Down
6 changes: 3 additions & 3 deletions src/stores/EpgController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ export default class EpgController {
};

getEpgService = (item: PlaylistItem) => {
const scheduleType = item?.scheduleType || EPG_TYPE.JWP;
const service = getNamedModule(EpgService, scheduleType);
const scheduleType = item?.scheduleType || EPG_TYPE.jwp;
const service = getNamedModule(EpgService, scheduleType?.toLowerCase());

if (!service) {
throw Error(`No epg service was added for the ${scheduleType} schedule type`);
console.error(`No epg service was added for the ${scheduleType} schedule type`);
}

return service;
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/livePlaylist.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"pubdate": 1615480440,
"description": "A 24x7 airing of long films released by Blender Open Movie Project, including Elephants Dream, Big Buck Bunny, Sintel, Tears Of Steel, and Cosmos Laundromat.",
"tags": "live",
"scheduleType": "JWP",
"scheduleType": "jwp",
"scheduleUrl": "/epg/jwChannel.json",
"catchupHours": "7",
"sources": [
Expand Down Expand Up @@ -104,7 +104,7 @@
"pubdate": 1615480440,
"description": "A 24x7 airing of long films released by Blender Open Movie Project, including Elephants Dream, Big Buck Bunny, Sintel, Tears Of Steel, and Cosmos Laundromat.",
"tags": "live",
"scheduleType": "JW",
"scheduleType": "jwp",
"scheduleUrl": "/epg/jwChannel.json",
"sources": [
{
Expand Down Expand Up @@ -157,7 +157,7 @@
"pubdate": 1615480440,
"description": "A 24x7 airing of long films released by Blender Open Movie Project, including Elephants Dream, Big Buck Bunny, Sintel, Tears Of Steel, and Cosmos Laundromat.",
"tags": "live",
"scheduleType": "JW",
"scheduleType": "jwp",
"scheduleUrl": "/epg/does-not-exist.json",
"sources": [
{
Expand Down Expand Up @@ -210,7 +210,7 @@
"pubdate": 1615480440,
"description": "A 24x7 airing of long films released by Blender Open Movie Project, including Elephants Dream, Big Buck Bunny, Sintel, Tears Of Steel, and Cosmos Laundromat.",
"tags": "live",
"scheduleType": "JW",
"scheduleType": "jwp",
"scheduleUrl": "/epg/network-error.json",
"sources": [
{
Expand Down

0 comments on commit be774d4

Please sign in to comment.