fix platfrom tests

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-08-24 15:03:47 +02:00
parent 739c5a5300
commit 8f4ba43b70
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
4 changed files with 13 additions and 11 deletions

View File

@ -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

View File

@ -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'

View File

@ -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 {

View File

@ -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}"
}
}