1bf22a8f95
- 新增 COMPANY_INFO.displayName 属性用于页面标题和SEO元数据 - 统一所有页面 metadata 使用 displayName(简体"睿新致远") - 视觉展示元素保留 shortName(繁体"睿新致遠"配合青柳隷書字体) - 修复关于/联系/团队页面标题中公司名重复出现的问题 - 修复新闻ID从数字改为SEO友好slug - 更新结构化数据使用完整公司名 - 修复ESLint报错:引号转义、组件displayName、any类型替换
62 lines
2.4 KiB
TypeScript
62 lines
2.4 KiB
TypeScript
import { render } from '@testing-library/react';
|
|
import '@testing-library/jest-dom';
|
|
import { OrganizationSchema, WebsiteSchema } from './structured-data';
|
|
import { COMPANY_INFO } from '@/lib/constants';
|
|
|
|
describe('StructuredData', () => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
describe('OrganizationSchema', () => {
|
|
it('should render organization schema', () => {
|
|
const { container } = render(<OrganizationSchema />);
|
|
const script = container.querySelector('script[type="application/ld+json"]');
|
|
expect(script).toBeInTheDocument();
|
|
});
|
|
|
|
it('should contain organization name', () => {
|
|
const { container } = render(<OrganizationSchema />);
|
|
const script = container.querySelector('script[type="application/ld+json"]');
|
|
const schema = JSON.parse(script?.textContent || '{}');
|
|
expect(schema.name).toBe(COMPANY_INFO.name);
|
|
});
|
|
|
|
it('should contain organization type', () => {
|
|
const { container } = render(<OrganizationSchema />);
|
|
const script = container.querySelector('script[type="application/ld+json"]');
|
|
const schema = JSON.parse(script?.textContent || '{}');
|
|
expect(schema['@type']).toBe('Organization');
|
|
});
|
|
|
|
it('should contain URL', () => {
|
|
const { container } = render(<OrganizationSchema />);
|
|
const script = container.querySelector('script[type="application/ld+json"]');
|
|
const schema = JSON.parse(script?.textContent || '{}');
|
|
expect(schema.url).toBe('https://www.novalon.cn');
|
|
});
|
|
});
|
|
|
|
describe('WebsiteSchema', () => {
|
|
it('should render website schema', () => {
|
|
const { container } = render(<WebsiteSchema />);
|
|
const script = container.querySelector('script[type="application/ld+json"]');
|
|
expect(script).toBeInTheDocument();
|
|
});
|
|
|
|
it('should contain website type', () => {
|
|
const { container } = render(<WebsiteSchema />);
|
|
const script = container.querySelector('script[type="application/ld+json"]');
|
|
const schema = JSON.parse(script?.textContent || '{}');
|
|
expect(schema['@type']).toBe('WebSite');
|
|
});
|
|
|
|
it('should contain website name', () => {
|
|
const { container } = render(<WebsiteSchema />);
|
|
const script = container.querySelector('script[type="application/ld+json"]');
|
|
const schema = JSON.parse(script?.textContent || '{}');
|
|
expect(schema.name).toBe(COMPANY_INFO.name);
|
|
});
|
|
});
|
|
});
|