-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added support for default locale
- Loading branch information
1 parent
fd6a693
commit fa9cbef
Showing
4 changed files
with
41 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,9 @@ import * as fs from 'fs'; | |
describe('AppController', () => { | ||
let controller: AppController; | ||
let mockHttp: { post: jest.Mock }; | ||
const delpoymentData: DeploymentInfo = { | ||
const deploymentData: DeploymentInfo = { | ||
name: 'test-name', | ||
locale: 'de', | ||
username: 'test-username', | ||
email: '[email protected]', | ||
client: 'test-client', | ||
|
@@ -42,7 +43,7 @@ describe('AppController', () => { | |
throwError(() => new UnauthorizedException()), | ||
); | ||
|
||
controller.deployApp(delpoymentData).subscribe({ | ||
controller.deployApp(deploymentData).subscribe({ | ||
error: (err) => { | ||
expect(err).toBeInstanceOf(UnauthorizedException); | ||
done(); | ||
|
@@ -51,7 +52,7 @@ describe('AppController', () => { | |
}); | ||
|
||
it('should throw bad request exception if data has wrong format', (done) => { | ||
const invalidData = { ...delpoymentData, name: 'with space' }; | ||
const invalidData = { ...deploymentData, name: 'with space' }; | ||
|
||
controller.deployApp(invalidData).subscribe({ | ||
error: (err) => { | ||
|
@@ -65,11 +66,29 @@ describe('AppController', () => { | |
const mockWs = { write: jest.fn(), close: jest.fn() }; | ||
jest.spyOn(fs, 'createWriteStream').mockReturnValue(mockWs as any); | ||
|
||
await firstValueFrom(controller.deployApp(delpoymentData)); | ||
await firstValueFrom(controller.deployApp(deploymentData)); | ||
|
||
expect(mockWs.write).toHaveBeenCalledWith( | ||
'test-name [email protected] test-username test-base y n', | ||
'test-name de [email protected] test-username test-base y n', | ||
); | ||
expect(mockWs.close).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should use the default locale if empty or omitted', async () => { | ||
const mockWs = { write: jest.fn(), close: jest.fn() }; | ||
jest.spyOn(fs, 'createWriteStream').mockReturnValue(mockWs as any); | ||
|
||
const withoutLocale = { ...deploymentData, locale: '' }; | ||
await firstValueFrom(controller.deployApp(withoutLocale)); | ||
expect(mockWs.write).toHaveBeenCalledWith( | ||
'test-name en [email protected] test-username test-base y n', | ||
); | ||
|
||
mockWs.write.mockReset(); | ||
delete withoutLocale.locale; | ||
await firstValueFrom(controller.deployApp(withoutLocale)); | ||
expect(mockWs.write).toHaveBeenCalledWith( | ||
'test-name en [email protected] test-username test-base y n', | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export class DeploymentInfo { | ||
name: string; | ||
locale?: string; | ||
username: string; | ||
email: string; | ||
backend: boolean; | ||
|