From bf8f00c0d2da25be45e5752a3c76f363e89d40c9 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sat, 18 Apr 2026 07:31:27 +0300 Subject: [PATCH] Update foxtel.com.au.test.js --- sites/foxtel.com.au/foxtel.com.au.test.js | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/sites/foxtel.com.au/foxtel.com.au.test.js b/sites/foxtel.com.au/foxtel.com.au.test.js index 3485c6f2a..7046fac9b 100644 --- a/sites/foxtel.com.au/foxtel.com.au.test.js +++ b/sites/foxtel.com.au/foxtel.com.au.test.js @@ -1,3 +1,4 @@ +const axios = require('axios') const { parser, url, request } = require('./foxtel.com.au.config.js') const fs = require('fs') const path = require('path') @@ -7,6 +8,23 @@ const customParseFormat = require('dayjs/plugin/customParseFormat') dayjs.extend(customParseFormat) dayjs.extend(utc) +jest.mock('axios') + +axios.get.mockImplementation(url => { + if ( + url === + 'https://www.foxtel.com.au/webepg/ws/foxtel/event/174868153?movieHeight=213&tvShowHeight=213®ionId=8336' + ) { + return Promise.resolve({ + data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/program_1.json'))) + }) + } else { + return Promise.resolve({ + data: '{}' + }) + } +}) + const date = dayjs.utc('2022-11-08', 'YYYY-MM-DD').startOf('d') const channel = { site_id: 'Channel-9-Sydney/NIN', @@ -26,10 +44,10 @@ it('can generate valid request headers', () => { }) }) -it('can parse response', () => { +it('can parse response', async () => { const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) - let results = parser({ content }) + let results = await parser({ content }) results = results.map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() @@ -41,6 +59,8 @@ it('can parse response', () => { stop: '2022-11-07T13:30:00.000Z', title: 'The Equalizer', sub_title: 'Glory', + description: + "While Danny chaperones Grace's winter formal, terrorists seize the venue and hold everyone hostage in order to kidnap a diplomat's son.", image: 'https://images1.resources.foxtel.com.au/store2/mount1/16/3/69e0v.jpg?maxheight=90&limit=91aa1c7a2c485aeeba0706941f79f111adb35830', rating: { @@ -52,8 +72,8 @@ it('can parse response', () => { }) }) -it('can handle empty guide', () => { - const result = parser({ +it('can handle empty guide', async () => { + const result = await parser({ content: fs.readFileSync(path.resolve(__dirname, '__data__/no-content.html')) }) expect(result).toMatchObject([])