mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
fix platfrom tests
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
739c5a5300
commit
8f4ba43b70
@ -50,7 +50,7 @@ describe('i18n', () => {
|
||||
it('should emit status and return id when no loader', async () => {
|
||||
expect.assertions(2)
|
||||
const plugin = 'plugin-without-string-loader'
|
||||
const message = `${plugin}.string.id`
|
||||
const message = `${plugin}:string:id`
|
||||
|
||||
const checkStatus = new Status(Severity.ERROR, platform.status.NoLoaderForStrings, { plugin })
|
||||
const eventListener = async (event: string, data: any): Promise<void> => {
|
||||
@ -65,7 +65,7 @@ describe('i18n', () => {
|
||||
it('should emit status and return id when bad loader', async () => {
|
||||
expect.assertions(2)
|
||||
const plugin = 'component-for-bad-loader'
|
||||
const message = `${plugin}.string.id`
|
||||
const message = `${plugin}:string:id`
|
||||
const errorMessage = 'bad loader'
|
||||
addStringsLoader(plugin as Plugin, (locale: string) => {
|
||||
throw new Error(errorMessage)
|
||||
@ -83,7 +83,7 @@ describe('i18n', () => {
|
||||
|
||||
it('should cache error', async () => {
|
||||
const plugin = 'component'
|
||||
const message = `${plugin}.string.id`
|
||||
const message = `${plugin}:string:id`
|
||||
|
||||
const checkStatus = new Status(Severity.ERROR, platform.status.NoLoaderForStrings, { plugin })
|
||||
let calls = 0
|
||||
|
@ -26,7 +26,7 @@ describe('ident', () => {
|
||||
MyString: '' as StatusCode<{}>
|
||||
}
|
||||
})
|
||||
expect(ids.status.MyString).toBe('test.status.MyString')
|
||||
expect(ids.status.MyString).toBe('test:status:MyString')
|
||||
})
|
||||
|
||||
it('should merge ids', () => {
|
||||
@ -43,9 +43,9 @@ describe('ident', () => {
|
||||
X: '' as StatusCode<{}>
|
||||
}
|
||||
})
|
||||
expect(merged.resource.MyString).toBe('test.resource.MyString')
|
||||
expect(merged.resource.OneMore).toBe('test.resource.OneMore')
|
||||
expect(merged.more.X).toBe('test.more.X')
|
||||
expect(merged.resource.MyString).toBe('test:resource:MyString')
|
||||
expect(merged.resource.OneMore).toBe('test:resource:OneMore')
|
||||
expect(merged.more.X).toBe('test:more:X')
|
||||
})
|
||||
|
||||
it('should fail overwriting ids', () => {
|
||||
@ -65,12 +65,12 @@ describe('ident', () => {
|
||||
|
||||
it('should fail to parse id', () => {
|
||||
expect(() => _parseId('bad id' as Id)).toThrowError(
|
||||
'ERROR: platform.status.InvalidId'
|
||||
'ERROR: platform:status:InvalidId'
|
||||
)
|
||||
})
|
||||
|
||||
it('should parse id', () => {
|
||||
expect(_parseId('comp.res.X' as Id)).toEqual({
|
||||
expect(_parseId('comp:res:X' as Id)).toEqual({
|
||||
kind: 'res',
|
||||
component: 'comp',
|
||||
name: 'X'
|
||||
|
@ -73,7 +73,7 @@ async function broadcastEvent (event: string, data: any): Promise<void> {
|
||||
* @returns
|
||||
*/
|
||||
export async function setPlatformStatus (status: Status | Error): Promise<void> {
|
||||
console.log('platform status', status)
|
||||
// console.log('platform status', status)
|
||||
if (status instanceof Error) {
|
||||
return await broadcastEvent(PlatformEvent, unknownError(status))
|
||||
} else {
|
||||
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"status": {
|
||||
"loadingPlugin": "Loading plugin '<b>'{plugin}'</b>'..."
|
||||
"LoadingPlugin": "Loading plugin '<b>'{plugin}'</b>'...",
|
||||
"UnknownError": "Unknown error: {message}",
|
||||
"InvaldId": "Invalid Id: {id}"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user