From f495161f9dd0c0f4041338c5a948eb45f6087fb7 Mon Sep 17 00:00:00 2001 From: Karina Thomas Date: Fri, 6 Dec 2024 12:55:41 +0000 Subject: [PATCH 1/2] Delete getRadioService as it is no longer required --- src/app/routes/utils/getRadioService/index.js | 17 ----- .../utils/getRadioService/index.test.js | 69 ------------------- 2 files changed, 86 deletions(-) delete mode 100644 src/app/routes/utils/getRadioService/index.js delete mode 100644 src/app/routes/utils/getRadioService/index.test.js diff --git a/src/app/routes/utils/getRadioService/index.js b/src/app/routes/utils/getRadioService/index.js deleted file mode 100644 index ed2517dff71..00000000000 --- a/src/app/routes/utils/getRadioService/index.js +++ /dev/null @@ -1,17 +0,0 @@ -const RADIO_SERVICE_MAPPINGS = { - indonesia: 'indonesian', - persian: 'dari', - afaanoromoo: 'oromo', - bengali: 'bangla', -}; - -export default ({ service, pathname }) => { - const isPodcast = pathname.includes('podcasts'); - const isPersianRadioMasterBrand = pathname.includes('bbc_persian_radio'); - - if (service === 'persian' && (isPersianRadioMasterBrand || isPodcast)) { - return 'persian'; - } - - return RADIO_SERVICE_MAPPINGS[service] || service; -}; diff --git a/src/app/routes/utils/getRadioService/index.test.js b/src/app/routes/utils/getRadioService/index.test.js deleted file mode 100644 index a98d888766a..00000000000 --- a/src/app/routes/utils/getRadioService/index.test.js +++ /dev/null @@ -1,69 +0,0 @@ -import getRadioService from '.'; - -it('should return "indonesian" for the indonesia service', () => { - const actual = getRadioService({ - service: 'indonesia', - pathname: 'bbc_indonesian_radio', - }); - const expected = 'indonesian'; - - expect(actual).toEqual(expected); -}); - -it('should return "dari" for the persian service', () => { - const actual = getRadioService({ - service: 'persian', - pathname: 'bbc_dari_radio', - }); - const expected = 'dari'; - - expect(actual).toEqual(expected); -}); - -it('should return "persian" for the persian service when pathname includes bbc_persian_radio', () => { - const actual = getRadioService({ - service: 'persian', - pathname: 'bbc_persian_radio', - }); - const expected = 'persian'; - - expect(actual).toEqual(expected); -}); - -it('should return "oromo" for the afaanoromoo service', () => { - const actual = getRadioService({ - service: 'afaanoromoo', - pathname: 'bbc_afaanoromoo_radio', - }); - const expected = 'oromo'; - - expect(actual).toEqual(expected); -}); - -it('should return "bangla" for the bengali service', () => { - const actual = getRadioService({ - service: 'bengali', - pathname: 'bbc_bangla_radio', - }); - const expected = 'bangla'; - - expect(actual).toEqual(expected); -}); - -it('should return service passed in when there is no mapping', () => { - const actual = getRadioService({ - service: 'pidgin', - pathname: 'mock-pathname', - }); - - expect(actual).toEqual('pidgin'); -}); - -it('should return persian for podcast when there is no bbc_persian_radio masterbrand', () => { - const actual = getRadioService({ - service: 'persian', - pathname: '/persian/podcasts/example', - }); - - expect(actual).toEqual('persian'); -}); From a044cb75b77c6fcc1f301814214b090d53dcdb4d Mon Sep 17 00:00:00 2001 From: Karina Thomas Date: Fri, 6 Dec 2024 12:55:56 +0000 Subject: [PATCH 2/2] Delete getPlaceholderImageUrl as it is no longer references --- .../utils/getPlaceholderImageUrl/index.js | 18 ------------------ .../utils/getPlaceholderImageUrl/index.test.js | 17 ----------------- 2 files changed, 35 deletions(-) delete mode 100644 src/app/routes/utils/getPlaceholderImageUrl/index.js delete mode 100644 src/app/routes/utils/getPlaceholderImageUrl/index.test.js diff --git a/src/app/routes/utils/getPlaceholderImageUrl/index.js b/src/app/routes/utils/getPlaceholderImageUrl/index.js deleted file mode 100644 index 28e5013730f..00000000000 --- a/src/app/routes/utils/getPlaceholderImageUrl/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import is from 'ramda/src/is'; -import { getEnvConfig } from '#app/lib/utilities/getEnvConfig'; - -export const FALLBACK_PLACEHOLDER_IMAGE_URL = `${ - getEnvConfig().SIMORGH_PUBLIC_STATIC_ASSETS_ORIGIN -}${ - getEnvConfig().SIMORGH_PUBLIC_STATIC_ASSETS_PATH -}images/media_placeholder.png`; - -const getPlaceholderImageUrl = imageUrl => { - if (imageUrl && is(String, imageUrl)) { - return `https://${imageUrl.replace('$recipe', '1024x576')}`; - } - - return FALLBACK_PLACEHOLDER_IMAGE_URL; -}; - -export default getPlaceholderImageUrl; diff --git a/src/app/routes/utils/getPlaceholderImageUrl/index.test.js b/src/app/routes/utils/getPlaceholderImageUrl/index.test.js deleted file mode 100644 index c3d5581ac93..00000000000 --- a/src/app/routes/utils/getPlaceholderImageUrl/index.test.js +++ /dev/null @@ -1,17 +0,0 @@ -import getPlaceholderImageUrl from '.'; - -describe('generatePlaceholderImageUrl', () => { - test('should generate correct image url when url provided', () => { - const url = getPlaceholderImageUrl( - 'ichef.bbci.co.uk/images/ic/$recipe/p063j1dv.jpg', - ); - expect(url).toEqual( - 'https://ichef.bbci.co.uk/images/ic/1024x576/p063j1dv.jpg', - ); - }); - - test('should use placeholder when image not provided', () => { - const url = getPlaceholderImageUrl(null); - expect(url).toEqual('http://localhost:7080/images/media_placeholder.png'); - }); -});