chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -13,31 +13,31 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import { i18nContext } from '../../src/i18n-provider/context';
|
||||
|
||||
describe('i18n-provider/context', () => {
|
||||
it('should create a context with default values', () => {
|
||||
// 验证 i18nContext 是否被正确创建
|
||||
// Verify that i18nContext was created correctly
|
||||
expect(i18nContext).toBeDefined();
|
||||
|
||||
// 获取默认值 - 使用类型断言访问内部属性
|
||||
// @ts-expect-error - 访问内部属性
|
||||
// Get Default Values - Use Type Assertions to Access Internal Properties
|
||||
// @ts-expect-error - access internal properties
|
||||
const defaultValue = i18nContext._currentValue;
|
||||
|
||||
// 验证默认值中的 i18n 对象是否存在
|
||||
// Verify that the i18n object in the default value exists
|
||||
expect(defaultValue.i18n).toBeDefined();
|
||||
|
||||
// 验证 t 函数是否存在
|
||||
// Verify that the t function exists
|
||||
expect(defaultValue.i18n.t).toBeDefined();
|
||||
expect(typeof defaultValue.i18n.t).toBe('function');
|
||||
|
||||
// 验证 t 函数的行为
|
||||
// Verify the behavior of the t function
|
||||
expect(defaultValue.i18n.t('test-key')).toBe('test-key');
|
||||
|
||||
// 验证 i18nContext 是一个对象
|
||||
// Verify that i18nContext is an object
|
||||
expect(typeof i18nContext).toBe('object');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ describe('I18nProvider', () => {
|
||||
const provider = new I18nProvider({ children });
|
||||
const result = provider.render().props.children;
|
||||
|
||||
// 验证渲染结果
|
||||
// Validate the render result
|
||||
expect(result).toBeDefined();
|
||||
expect(result.props).toBeDefined();
|
||||
expect(result.props.value).toBeDefined();
|
||||
@@ -48,7 +48,7 @@ describe('I18nProvider', () => {
|
||||
expect(typeof result.props.value.i18n.t).toBe('function');
|
||||
expect(result.props.children).toBe(children);
|
||||
|
||||
// 验证默认的 t 函数行为
|
||||
// Verify the default t function behavior
|
||||
const defaultT = result.props.value.i18n.t;
|
||||
expect(defaultT('test-key')).toBe('test-key');
|
||||
});
|
||||
@@ -69,14 +69,14 @@ describe('I18nProvider', () => {
|
||||
const provider = new I18nProvider({ children, i18n: mockI18n as any });
|
||||
const result = provider.render().props.children;
|
||||
|
||||
// 验证渲染结果
|
||||
// Validate the render result
|
||||
expect(result).toBeDefined();
|
||||
expect(result.props).toBeDefined();
|
||||
expect(result.props.value).toBeDefined();
|
||||
expect(result.props.value.i18n).toBe(mockI18n);
|
||||
expect(result.props.children).toBe(children);
|
||||
|
||||
// 验证使用了提供的 i18n
|
||||
// Verify that the provided i18n is used.
|
||||
const key = 'test-key';
|
||||
result.props.value.i18n.t(key);
|
||||
expect(mockI18n.t).toHaveBeenCalledWith(key);
|
||||
|
||||
@@ -18,7 +18,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
import { I18n, initI18nInstance } from '../../src/raw';
|
||||
|
||||
// 模拟本地化资源
|
||||
// Simulate localized resources
|
||||
vi.mock('../../src/resource.ts', () => ({
|
||||
default: {
|
||||
en: { i18n: { test: 'Test' } },
|
||||
|
||||
Reference in New Issue
Block a user