Skip to content

Commit 5c8c499

Browse files
committed
name convertItem to localizeItem
1 parent a9683ad commit 5c8c499

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/plugins/newsfeed/public/lib/convert_items.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import moment from 'moment';
1010
import { omit } from 'lodash';
11-
import { validateIntegrity, validatePublishedDate, convertItem } from './convert_items';
11+
import { validateIntegrity, validatePublishedDate, localizeItem } from './convert_items';
1212
import type { ApiItem, NewsfeedItem } from '../types';
1313

1414
const createApiItem = (parts: Partial<ApiItem> = {}): ApiItem => ({
@@ -33,7 +33,7 @@ const createNewsfeedItem = (parts: Partial<NewsfeedItem> = {}): NewsfeedItem =>
3333
...parts,
3434
});
3535

36-
describe('convertItem', () => {
36+
describe('localizeItem', () => {
3737
const item = createApiItem({
3838
languages: ['en', 'fr'],
3939
title: {
@@ -62,7 +62,7 @@ describe('convertItem', () => {
6262
});
6363

6464
it('converts api items to newsfeed items using the specified language', () => {
65-
expect(convertItem(item, 'fr')).toMatchObject({
65+
expect(localizeItem(item, 'fr')).toMatchObject({
6666
title: 'fr title',
6767
description: 'fr desc',
6868
linkText: 'fr link text',
@@ -73,7 +73,7 @@ describe('convertItem', () => {
7373
});
7474

7575
it('fallbacks to `en` is the language is not present', () => {
76-
expect(convertItem(item, 'de')).toMatchObject({
76+
expect(localizeItem(item, 'de')).toMatchObject({
7777
title: 'en title',
7878
description: 'en desc',
7979
linkText: 'en link text',

src/plugins/newsfeed/public/lib/convert_items.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { NEWSFEED_FALLBACK_LANGUAGE } from '../../common/constants';
1313
export const convertItems = (items: ApiItem[], userLanguage: string): NewsfeedItem[] => {
1414
return items
1515
.filter(validatePublishedDate)
16-
.map((item) => convertItem(item, userLanguage))
16+
.map((item) => localizeItem(item, userLanguage))
1717
.filter(validateIntegrity);
1818
};
1919

@@ -28,7 +28,7 @@ export const validatePublishedDate = (item: ApiItem): boolean => {
2828
return true;
2929
};
3030

31-
export const convertItem = (rawItem: ApiItem, userLanguage: string): NewsfeedItem => {
31+
export const localizeItem = (rawItem: ApiItem, userLanguage: string): NewsfeedItem => {
3232
const {
3333
expire_on: expireOnUtc,
3434
publish_on: publishOnUtc,

0 commit comments

Comments
 (0)