Skip to content

Commit

Permalink
mocks: improve django mock to return the actual text
Browse files Browse the repository at this point in the history
* adapt tests to new mock
  • Loading branch information
goapunk committed Aug 8, 2023
1 parent 9b49a28 commit 0772647
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
7 changes: 4 additions & 3 deletions __mocks__/djangoMock.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
gettext: () => 'mock text',
pgettext: () => 'mock text',
interpolate: () => 'mock text'
gettext: (text) => text,
pgettext: (context, text) => text,
ngettext: (number, text) => text + number,
interpolate: (fmt, data) => fmt
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports[`render <PollQuestion> with... -> multiple-choice -> non-open-asnwers 1`
<div
class="poll__help-text"
>
mock text
Multiple answers are possible.
</div>
<div
class="poll__rows"
Expand Down Expand Up @@ -70,7 +70,7 @@ exports[`render <PollQuestion> with... -> multiple-choice -> non-open-asnwers 1`
<div
class="poll__help-text"
>
mock text
Multiple answers are possible.
</div>
<div
class="poll__rows"
Expand Down Expand Up @@ -182,7 +182,7 @@ exports[`render <PollQuestion> with... -> multiple-choice -> open-asnwers 1`] =
<div
class="poll__help-text"
>
mock text
Multiple answers are possible.
</div>
<div
class="poll__rows"
Expand Down Expand Up @@ -237,7 +237,7 @@ exports[`render <PollQuestion> with... -> multiple-choice -> open-asnwers 1`] =
<div
class="poll__help-text"
>
mock text
Multiple answers are possible.
</div>
<div
class="poll__rows"
Expand Down
3 changes: 1 addition & 2 deletions adhocracy4/static/__tests__/TermsOfUseCheckbox.jest.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react'
import { render, screen, fireEvent } from '@testing-library/react'
import { TermsOfUseCheckbox } from '../TermsOfUseCheckbox'
import django from 'django'

test('One TermsOfUseCheckbox is showing', () => {
render(<TermsOfUseCheckbox id="test-checkbox" />)
const component = screen.getByLabelText(django.interpolate(), /mock text/)
const component = screen.getByLabelText('Yes, I have read and agree to this organisation\'s %(linkStart)s terms of use %(linkEnd)s.')
expect(component).toBeTruthy()
})

Expand Down

0 comments on commit 0772647

Please sign in to comment.