Skip to content

Commit

Permalink
fix: fixup previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarIthawi committed Feb 2, 2024
1 parent f6afa48 commit a2c3779
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/utils/i18n/scripts/generateSupportedLangs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@ afterEach(() => {

describe('help document', () => {
it('should print help for --help', () => {
let success = main({parameters: '--help'});
let success = main({
i18nMessagesDir: '--help',
});
expect(logHistory.latest).toMatch(
"generateSupportedLangs.js — Script to generate the 'src/i18n/messages/currentlySupportedLangs.jsx'"
);
expect(success).toBe(true);
});

it('should print help for -h', () => {
let success = main({parameters: '--help'});
let success = main({
i18nMessagesDir: '--help',
});
expect(logHistory.latest).toMatch(
"generateSupportedLangs.js — Script to generate the 'src/i18n/messages/currentlySupportedLangs.jsx'"
);
Expand All @@ -66,11 +70,11 @@ describe('help document', () => {

describe('generate with three languages', () => {
const success = main({
i18nMessagesDir: `${sempleAppsDirectory}/src/i18n/messages`,
i18nMessagesDir: `${sempleAppsDirectory}/app-with-translations/src/i18n/messages`,
});

expect(writeFileHistory.log.length).toBe(1);
expect(writeFileHistory.latest.filename).toBe(`${sempleAppsDirectory}/src/i18n/messages/currentlySupportedLangs.jsx`);
expect(writeFileHistory.latest.filename).toBe(`${sempleAppsDirectory}/app-with-translations/src/i18n/messages/currentlySupportedLangs.jsx`);
expect(success).toBe(true); // Languages generated successfully

// It should write the file with the following content:
Expand Down Expand Up @@ -100,21 +104,21 @@ describe('generate without languages', () => {
i18nMessagesDir: `${sempleAppsDirectory}/app-without-translations/src/i18n/messages`,
});

expect(writeFileHistory.log.length).toBe(0);
expect(success).toBe(false); // No languages to generate

// It should fail with the following error message:
expect(logHistory.latest).toContain('generateSupportedLangs.js: Error: No language files found in the "');

expect(writeFileHistory.log.length).toBe(0);
expect(success).toBe(false); // No languages to generate
});

describe('generate without MESSAGES_DIR parameter', () => {
const success = main({
i18nMessagesDir: '',
});

expect(writeFileHistory.log.length).toBe(0);
expect(success).toBe(false); // MESSAGES_DIR parameter is required

// It should fail with the following error message:
expect(logHistory.latest).toBe('generateSupportedLangs.js: Error: The "MESSAGES_DIR" parameter is required.\n');

expect(writeFileHistory.log.length).toBe(0);
expect(success).toBe(false); // MESSAGES_DIR parameter is required
});

0 comments on commit a2c3779

Please sign in to comment.