Skip to content

Commit 70ad56a

Browse files
committed
react/CardStats: update stat strings to include plural versions fixes #5370 and fix tests
1 parent 2136e4e commit 70ad56a

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

meinberlin/react/contrib/card/CardStats.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import django from 'django'
44
export const CardStats = (props) => {
55
const { permissions } = props
66

7-
const positiveRatingsStr = django.gettext('Likes')
8-
const negativeRatingsStr = django.gettext('Dislikes')
9-
const supportStr = django.gettext('Support')
7+
const positiveRatingsStr = django.ngettext('Like', 'Likes', props.positiveCount)
8+
const negativeRatingsStr = django.ngettext('Dislike', 'Dislikes', props.negativeCount)
9+
const supportStr = django.ngettext('Supporter', 'Supporters', props.positiveCount)
1010
const commentsStr = django.ngettext('Comment', 'Comments', props.commentCount)
1111
const votesStr = django.ngettext('Vote', 'Votes', props.voteCount)
1212

meinberlin/react/contrib/card/__tests__/Card.jest.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test('Renders a link to item details', () => {
6464
expect(comments.textContent).toEqual('7CommentComments')
6565
// don't do same check for likes count as it also finds the
6666
// dislikes as non exact string but 1 count is enough
67-
expect(dislikes.textContent).toEqual('1Dislikes')
67+
expect(dislikes.textContent).toEqual('1DislikeDislikes')
6868
expect(screen.getByText('My idea')).toBeTruthy()
6969
expect(screen.getByText('Item details')).toBeTruthy()
7070
})

meinberlin/react/contrib/card/__tests__/CardStats.jest.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test('2 phase: rating phase - can view comments and ratings count', () => {
2424
// strings constructed by ngettext will render both options as jest does not mock ngettext functionality,
2525
// it just returns both so we check for both as it is a predicatble outcome
2626
expect(comments.textContent).toEqual('18CommentComments')
27-
expect(dislikes.textContent).toEqual('1Dislikes')
27+
expect(dislikes.textContent).toEqual('1DislikeDislikes')
2828
expect(screen.queryByText('Votes')).toBeNull()
2929
})
3030

@@ -49,7 +49,7 @@ test('3 phase: support phase - can view comments and support count', () => {
4949
const likes = screen.getByText('Support', { exact: false })
5050

5151
expect(comments.textContent).toEqual('18CommentComments')
52-
expect(likes.textContent).toEqual('4Support')
52+
expect(likes.textContent).toEqual('4SupporterSupporters')
5353
expect(screen.queryByText('Dislikes')).toBeNull()
5454
expect(screen.queryByText('Likes')).toBeNull()
5555
expect(screen.queryByText('Votes')).toBeNull()

meinberlin/react/kiezkasse/__tests__/KiezkasseProposalsList.jest.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ test('Kiezkasse list - check render with required stats',
5252
expect(screen.getByText('This is a topic')).toBeTruthy()
5353
expect(screen.getByText('Category 1')).toBeTruthy()
5454
expect(screen.getByText('Label 2')).toBeTruthy()
55-
expect(screen.getByText('Likes')).toBeTruthy()
55+
expect(screen.getByText('LikeLikes')).toBeTruthy()
5656
expect(comments.textContent).toEqual('6CommentComments')
57-
expect(dislikes.textContent).toEqual('1Dislikes')
57+
expect(dislikes.textContent).toEqual('1DislikeDislikes')
5858

5959
// reverse overwrite of global.fetch
6060
await global.fetch.mockClear()

meinberlin/react/maptopicprio/__tests__/MapTopicPrioList.jest.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ test('Map Topic Prioritisation list - check render with required stats',
4545
const dislikes = screen.getByText('Dislikes', { exact: false })
4646

4747
expect(screen.getByText('This is a topic')).toBeTruthy()
48-
expect(screen.getByText('Likes')).toBeTruthy()
48+
expect(screen.getByText('LikeLikes')).toBeTruthy()
4949
expect(comments.textContent).toEqual('6CommentComments')
50-
expect(dislikes.textContent).toEqual('1Dislikes')
50+
expect(dislikes.textContent).toEqual('1DislikeDislikes')
5151

5252
// reverse overwrite of global.fetch
5353
await global.fetch.mockClear()

meinberlin/react/topicprio/__tests__/TopicPrioList.jest.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ test('Topic Prioritisation list - check render with required stats',
4545
const dislikes = screen.getByText('Dislikes', { exact: false })
4646

4747
expect(screen.getByText('This is a topic')).toBeTruthy()
48-
expect(screen.getByText('Likes')).toBeTruthy()
48+
expect(screen.getByText('LikeLikes')).toBeTruthy()
4949
expect(comments.textContent).toEqual('6CommentComments')
50-
expect(dislikes.textContent).toEqual('1Dislikes')
50+
expect(dislikes.textContent).toEqual('1DislikeDislikes')
5151

5252
// reverse overwrite of global.fetch
5353
await global.fetch.mockClear()

0 commit comments

Comments
 (0)