新增 HostBridge app.setBadgeCount 契约和 H5 能力门控 Expo 壳按平台声明能力并在 iOS 调用系统角标 API Tauri 壳通过主窗口设置任务栏角标并校验 payload 补齐角标能力测试、漂移检查和架构文档
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
|
|
import { buildMobileShellUrl } from './mobileShellUrl';
|
|
|
|
describe('buildMobileShellUrl', () => {
|
|
test('为 H5 附加原生移动壳上下文', () => {
|
|
const url = new URL(
|
|
buildMobileShellUrl('https://app.test/works/detail?work=PZ-1', {
|
|
platform: 'ios',
|
|
hostVersion: '0.1.0',
|
|
capabilities: ['host.getRuntime', 'share.open'],
|
|
}),
|
|
);
|
|
|
|
expect(url.searchParams.get('clientRuntime')).toBe('native_app');
|
|
expect(url.searchParams.get('clientType')).toBe('native_app');
|
|
expect(url.searchParams.get('hostShell')).toBe('expo_mobile');
|
|
expect(url.searchParams.get('hostPlatform')).toBe('ios');
|
|
expect(url.searchParams.get('hostVersion')).toBe('0.1.0');
|
|
expect(url.searchParams.get('bridgeVersion')).toBe('1');
|
|
expect(url.searchParams.get('hostCapabilities')).toBe(
|
|
'host.getRuntime,share.open',
|
|
);
|
|
expect(url.searchParams.get('work')).toBe('PZ-1');
|
|
});
|
|
|
|
test('支持按平台注入不同能力清单', () => {
|
|
const iosUrl = new URL(
|
|
buildMobileShellUrl('https://app.test/', {
|
|
platform: 'ios',
|
|
hostVersion: '0.1.0',
|
|
capabilities: ['host.getRuntime', 'app.setBadgeCount'],
|
|
}),
|
|
);
|
|
const androidUrl = new URL(
|
|
buildMobileShellUrl('https://app.test/', {
|
|
platform: 'android',
|
|
hostVersion: '0.1.0',
|
|
capabilities: ['host.getRuntime'],
|
|
}),
|
|
);
|
|
|
|
expect(iosUrl.searchParams.get('hostCapabilities')).toBe(
|
|
'host.getRuntime,app.setBadgeCount',
|
|
);
|
|
expect(androidUrl.searchParams.get('hostCapabilities')).toBe(
|
|
'host.getRuntime',
|
|
);
|
|
});
|
|
});
|