From 897c01986f6810bca078b85e53bdb3c14a25978a Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sat, 18 Apr 2026 09:08:29 +0300 Subject: [PATCH] Create aljazeera.com.test.js --- sites/aljazeera.com/aljazeera.com.test.js | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 sites/aljazeera.com/aljazeera.com.test.js diff --git a/sites/aljazeera.com/aljazeera.com.test.js b/sites/aljazeera.com/aljazeera.com.test.js new file mode 100644 index 000000000..751c1ad7a --- /dev/null +++ b/sites/aljazeera.com/aljazeera.com.test.js @@ -0,0 +1,55 @@ +const { parser, url, request } = require('./aljazeera.com.config.js') +const fs = require('fs') +const path = require('path') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const customParseFormat = require('dayjs/plugin/customParseFormat') +dayjs.extend(customParseFormat) +dayjs.extend(utc) + +const date = dayjs.utc('2026-04-22', 'YYYY-MM-DD').startOf('d') +const channel = { site_id: 'aje' } + +it('can generate valid url', () => { + expect(url({ channel })).toBe( + 'https://www.aljazeera.com/graphql?wp-site=aje&operationName=ArchipelagoSchedulePageQuery&variables=%7B%22postName%22%3A%22schedule%22%2C%22preview%22%3A%22%22%7D' + ) +}) + +it('can generate valid request headers', () => { + expect(request.headers({ channel })).toMatchObject({ + 'wp-site': 'aje' + }) +}) + +it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) + + const results = parser({ content, date }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + + return p + }) + + expect(results.length).toBe(35) + expect(results[0]).toMatchObject({ + title: 'NEWSHOUR', + description: 'Latest news and in-depth analysis from around the world.', + start: '2026-04-21T12:00:00.000Z', + stop: '2026-04-21T13:00:00.000Z' + }) + expect(results[34]).toMatchObject({ + title: 'Inside Story', + description: + 'Beyond the headlines to the heart of the news of the day. Al Jazeera gets the Inside Story from some of the best minds from around the globe.', + start: '2026-04-22T11:30:00.000Z', + stop: '2026-04-22T12:00:00.000Z' + }) +}) + +it('can handle empty guide', () => { + const results = parser({ content: '', date }) + + expect(results).toMatchObject([]) +})