chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -18,12 +18,12 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
import { RemoteWebWorker, register } from '../src/index';
// 获取模拟函数
// Get the simulation function
const mockCreateObjectURL = vi.mocked(URL.createObjectURL);
describe('RemoteWebWorker', () => {
beforeEach(() => {
// 清除模拟调用记录
// Clear simulated call record
vi.clearAllMocks();
});
@@ -63,10 +63,10 @@ describe('RemoteWebWorker', () => {
expect(mockCreateObjectURL).toHaveBeenCalledTimes(1);
// 验证创建的 Blob 内容
// Verify the content of the created blob
const blobArg = mockCreateObjectURL.mock.calls[0][0];
expect(blobArg).toBeInstanceOf(Blob);
// 由于 Blob 的内容无法直接访问,我们只能验证它被创建了
// Since the content of the blob cannot be accessed directly, we can only verify that it was created
});
it('应该处理非字符串 URL', () => {
@@ -84,14 +84,14 @@ describe('RemoteWebWorker', () => {
describe('register', () => {
it('应该将全局 Worker 替换为 RemoteWebWorker', () => {
// 创建一个模拟的全局对象
// Create a simulated global object
const mockGlobal = {
worker() {
/* 空函数 */
/* empty function */
},
};
// 将 worker 属性重命名为 Worker以便测试 register 函数
// Rename the worker property to Worker to test the register function
Object.defineProperty(mockGlobal, 'Worker', {
get() {
return this.worker;

View File

@@ -16,27 +16,27 @@
import { vi } from 'vitest';
// 定义一个模拟的 Worker
// Define a simulated Worker class
class MockWorker {
constructor(
public scriptURL: string,
public options: any,
) {}
// 添加 Worker 接口所需的方法
// Methods required to add a Worker interface
terminate(): void {
// 空实现
// empty implementation
}
postMessage(): void {
// 空实现
// empty implementation
}
onmessage = null;
onmessageerror = null;
}
// 全局模拟
// global simulation
global.Worker = MockWorker as any;
global.URL = {
createObjectURL: vi.fn().mockReturnValue('blob:mocked-object-url'),