Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add check for base description length #551

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,4 +511,26 @@ describe('invalid applications entries', () => {
'ValidationError: "applications[1]" contains a duplicate value',
)
})

it('errors on a base description that is over 50 characters', () => {
jest
.spyOn(i18next, 't')
.mockReturnValueOnce(
'It was the best of times, it was the worst of times',
)
const testDappObject = {
categories: [category],
applications: [
{
name: 'GoodDollar',
id: 'gooddollar',
categoryId: 'social-impact',
url: 'https://gooddapp.org/',
},
],
}
expect(`${schema.validate(testDappObject).error}`).toBe(
"ValidationError: \"categories[0].id\" failed custom validation because Localization key 'categories.social-impact' in 'locales/base.json' must not be longer than 50 characters",
)
})
})
6 changes: 6 additions & 0 deletions src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ const checkMatchingLocalization: CustomValidator = (value) => {
)
}

if (localizedValue.length > 50) {
throw new Error(
`Localization key '${value}' in 'locales/base.json' must not be longer than 50 characters`,
)
}

return value
}

Expand Down
Loading