From 2932771e913dbbfb2b3678685d00f9ff72ba27d6 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sun, 2 Feb 2025 06:28:45 +0300 Subject: [PATCH] Update abc.net.au.test.js --- sites/abc.net.au/abc.net.au.test.js | 67 ++++++++++++++--------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/sites/abc.net.au/abc.net.au.test.js b/sites/abc.net.au/abc.net.au.test.js index 769ee6ef..e4f87531 100644 --- a/sites/abc.net.au/abc.net.au.test.js +++ b/sites/abc.net.au/abc.net.au.test.js @@ -1,54 +1,51 @@ const { parser, url } = require('./abc.net.au.config.js') +const fs = require('fs') +const path = require('path') const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') dayjs.extend(utc) -const date = dayjs.utc('2022-12-22', 'YYYY-MM-DD').startOf('d') -const channel = { - site_id: 'Sydney#ABC1', - xmltv_id: 'ABCTV.au' -} +const date = dayjs.utc('2025-02-04', 'YYYY-MM-DD').startOf('d') +const channel = { site_id: 'Sydney#ABC1' } + it('can generate valid url', () => { - expect(url({ date, channel })).toBe('https://epg.abctv.net.au/processed/Sydney_2022-12-22.json') + expect(url({ date, channel })).toBe( + 'https://cdn.iview.abc.net.au/epg/processed/Sydney_2025-02-04.json' + ) }) it('can parse response', () => { - const content = - '{"date":"2022-12-22","region":"Sydney","schedule":[{"channel":"ABC1","listing":[{"consumer_advice":"Adult Themes, Drug Use, Violence","rating":"M","show_id":912747,"repeat":true,"description":"When tragedy strikes close to home, it puts head teacher Noah Taylor on a collision course with the criminals responsible. Can the Lyell team help him stop the cycle of violence?","title":"Silent Witness","crid":"ZW2178A004S00","start_time":"2022-12-22T00:46:00","series-crid":"ZW2178A","live":false,"captioning":true,"show_type":"Episode","series_num":22,"episode_title":"Lift Up Your Hearts (part Two)","length":58,"onair_title":"Silent Witness","end_time":"2022-12-22T01:44:00","genres":["Entertainment"],"image_file":"ZW2178A004S00_460.jpg","prog_slug":"silent-witness","episode_num":4}]}]}' - - const result = parser({ content, channel }).map(p => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) + const results = parser({ content, channel }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() return p }) - expect(result).toMatchObject([ - { - title: 'Silent Witness', - sub_title: 'Lift Up Your Hearts (part Two)', - description: - 'When tragedy strikes close to home, it puts head teacher Noah Taylor on a collision course with the criminals responsible. Can the Lyell team help him stop the cycle of violence?', - category: ['Entertainment'], - rating: { - system: 'ACB', - value: 'M' - }, - season: 22, - episode: 4, - image: 'https://www.abc.net.au/tv/common/images/publicity/ZW2178A004S00_460.jpg', - start: '2022-12-21T13:46:00.000Z', - stop: '2022-12-21T14:44:00.000Z' - } - ]) + expect(results.length).toBe(30) + expect(results[0]).toMatchObject({ + title: "Julia Zemiro's Home Delivery", + sub_title: 'Maggie Beer', + description: + "The kitchen Maggie Beer made famous in The Cook and the Chef may be in the heart of the Barossa Valley, but our most beloved foodie meets up with Julia where she grew up in Sydney's Lakemba.", + category: ['Entertainment', 'Factual'], + rating: { + system: 'ACB', + value: 'G' + }, + season: null, + episode: null, + image: 'https://www.abc.net.au/tv/common/images/publicity/LE1761H002S00_460.jpg', + start: '2025-02-03T12:40:00.000Z', + stop: '2025-02-03T13:09:00.000Z' + }) }) it('can handle empty guide', () => { - const result = parser( - { - content: - 'NoSuchKeyThe specified key does not exist.processed/Sydney_2023-01-17.json6MRHX5TJ12X39B3Y59rH6XRMrmkFywg8Kv58iqpI6O1fuOCuEbKa1HRRYa4buByXMBTvAhz8zuAK7X5D+ZN9ZuWxyGs=' - }, + const results = parser({ + content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html')), channel - ) - expect(result).toMatchObject([]) + }) + + expect(results).toMatchObject([]) })