mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-08 21:27:45 +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 () => {
|
it('should emit status and return id when no loader', async () => {
|
||||||
expect.assertions(2)
|
expect.assertions(2)
|
||||||
const plugin = 'plugin-without-string-loader'
|
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 checkStatus = new Status(Severity.ERROR, platform.status.NoLoaderForStrings, { plugin })
|
||||||
const eventListener = async (event: string, data: any): Promise<void> => {
|
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 () => {
|
it('should emit status and return id when bad loader', async () => {
|
||||||
expect.assertions(2)
|
expect.assertions(2)
|
||||||
const plugin = 'component-for-bad-loader'
|
const plugin = 'component-for-bad-loader'
|
||||||
const message = `${plugin}.string.id`
|
const message = `${plugin}:string:id`
|
||||||
const errorMessage = 'bad loader'
|
const errorMessage = 'bad loader'
|
||||||
addStringsLoader(plugin as Plugin, (locale: string) => {
|
addStringsLoader(plugin as Plugin, (locale: string) => {
|
||||||
throw new Error(errorMessage)
|
throw new Error(errorMessage)
|
||||||
@ -83,7 +83,7 @@ describe('i18n', () => {
|
|||||||
|
|
||||||
it('should cache error', async () => {
|
it('should cache error', async () => {
|
||||||
const plugin = 'component'
|
const plugin = 'component'
|
||||||
const message = `${plugin}.string.id`
|
const message = `${plugin}:string:id`
|
||||||
|
|
||||||
const checkStatus = new Status(Severity.ERROR, platform.status.NoLoaderForStrings, { plugin })
|
const checkStatus = new Status(Severity.ERROR, platform.status.NoLoaderForStrings, { plugin })
|
||||||
let calls = 0
|
let calls = 0
|
||||||
|
@ -26,7 +26,7 @@ describe('ident', () => {
|
|||||||
MyString: '' as StatusCode<{}>
|
MyString: '' as StatusCode<{}>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
expect(ids.status.MyString).toBe('test.status.MyString')
|
expect(ids.status.MyString).toBe('test:status:MyString')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should merge ids', () => {
|
it('should merge ids', () => {
|
||||||
@ -43,9 +43,9 @@ describe('ident', () => {
|
|||||||
X: '' as StatusCode<{}>
|
X: '' as StatusCode<{}>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
expect(merged.resource.MyString).toBe('test.resource.MyString')
|
expect(merged.resource.MyString).toBe('test:resource:MyString')
|
||||||
expect(merged.resource.OneMore).toBe('test.resource.OneMore')
|
expect(merged.resource.OneMore).toBe('test:resource:OneMore')
|
||||||
expect(merged.more.X).toBe('test.more.X')
|
expect(merged.more.X).toBe('test:more:X')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should fail overwriting ids', () => {
|
it('should fail overwriting ids', () => {
|
||||||
@ -65,12 +65,12 @@ describe('ident', () => {
|
|||||||
|
|
||||||
it('should fail to parse id', () => {
|
it('should fail to parse id', () => {
|
||||||
expect(() => _parseId('bad id' as Id)).toThrowError(
|
expect(() => _parseId('bad id' as Id)).toThrowError(
|
||||||
'ERROR: platform.status.InvalidId'
|
'ERROR: platform:status:InvalidId'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should parse id', () => {
|
it('should parse id', () => {
|
||||||
expect(_parseId('comp.res.X' as Id)).toEqual({
|
expect(_parseId('comp:res:X' as Id)).toEqual({
|
||||||
kind: 'res',
|
kind: 'res',
|
||||||
component: 'comp',
|
component: 'comp',
|
||||||
name: 'X'
|
name: 'X'
|
||||||
|
@ -73,7 +73,7 @@ async function broadcastEvent (event: string, data: any): Promise<void> {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function setPlatformStatus (status: Status | Error): Promise<void> {
|
export async function setPlatformStatus (status: Status | Error): Promise<void> {
|
||||||
console.log('platform status', status)
|
// console.log('platform status', status)
|
||||||
if (status instanceof Error) {
|
if (status instanceof Error) {
|
||||||
return await broadcastEvent(PlatformEvent, unknownError(status))
|
return await broadcastEvent(PlatformEvent, unknownError(status))
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"status": {
|
"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