Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
localization: Assert on missing translation parameters in test
Browse files Browse the repository at this point in the history
  • Loading branch information
tbergquist-godaddy authored and RobinCsl committed Jan 3, 2020
1 parent e7a3bed commit c5008ef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/localization/src/__tests__/TranslationHelpers.test.js
Original file line number Diff line number Diff line change
@@ -36,19 +36,29 @@ describe('getTranslation:', () => {
});

it('handles changed translations', () => {
const spy = jest.spyOn(console, 'warn').mockImplementation(jest.fn());
const translationId = 'single_hotel.book_now.description';
const translatedString = 'Počet hostů: %1$@ · Počet pokojů: %2$@ · %3$@';
expect(getTranslation(translatedString, translationId, vocabulary)).toBe(
'Počet hostů: __1_personCount__ · Počet pokojů: __2_numberOfRooms__ · ',
);
expect(spy).toHaveBeenCalledWith(
'Missing translation parameter for single_hotel.book_now.description variableIndex = 3',
);
spy.mockRestore();
});

it('returns translated string if parameter matching is not possible', () => {
const spy = jest.spyOn(console, 'warn').mockImplementation(jest.fn());
const translationId = 'hotels.gallery.pagination';
const translatedString = '%1$@ of %2$@';
const mistake = ' and MISTAKE %3$@';
expect(getTranslation(translatedString + mistake, translationId, vocabulary)).toBe(
'__1_photoNumber__ of __2_totalPhotos__ and MISTAKE ',
);
expect(spy).toHaveBeenCalledWith(
'Missing translation parameter for hotels.gallery.pagination variableIndex = 3',
);
spy.mockRestore();
});
});

0 comments on commit c5008ef

Please sign in to comment.