Skip to content

Commit 609880d

Browse files
authored
[Angular] Add test to check titles (#31802)
1 parent 030b291 commit 609880d

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

generators/angular/generator.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,22 @@ describe(`generator - ${clientFramework}`, () => {
187187
});
188188
});
189189
});
190+
191+
describe('enableTranslation: false', () => {
192+
before(async () => {
193+
await helpers
194+
.runJHipster(generator)
195+
.withJHipsterConfig({
196+
clientFramework,
197+
enableTranslation: false,
198+
})
199+
.withSharedApplication({ getWebappTranslation: () => 'translated-value' })
200+
.withMockedSource()
201+
.withMockedGenerators(['jhipster:common', 'jhipster:client:i18n']);
202+
});
203+
204+
it('should add value title in *.routes.ts files', () => {
205+
runResult.assertFileContent(`${CLIENT_MAIN_SRC_DIR}app/admin/admin.routes.ts`, /title: 'translated-value'/);
206+
});
207+
});
190208
});

generators/angular/support/translate-angular.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,23 @@ title: 'translated-value-activate.title2-1',
255255
});
256256
});
257257

258+
describe('.routes.ts files', () => {
259+
const extension = '.routes.ts';
260+
261+
it('should translate title fields with translation values', () => {
262+
const body = `
263+
title: 'activate.title1',
264+
title: 'activate.title2',
265+
`;
266+
expect(replaceAngularTranslations(body, extension)).toMatchInlineSnapshot(`
267+
"
268+
title: 'translated-value-activate.title1-0',
269+
title: 'translated-value-activate.title2-1',
270+
"
271+
`);
272+
});
273+
});
274+
258275
describe('.module.ts files', () => {
259276
const extension = '.module.ts';
260277

0 commit comments

Comments
 (0)