Reinit project
This commit is contained in:
1
src/pages/__tests__/__mocks__/umi-plugin-locale.ts
Normal file
1
src/pages/__tests__/__mocks__/umi-plugin-locale.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const formatMessage = (): string => 'Mock text';
|
||||
21
src/pages/__tests__/index.test.tsx
Normal file
21
src/pages/__tests__/index.test.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'jest';
|
||||
import Index from '..';
|
||||
import React from 'react';
|
||||
import renderer, { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer';
|
||||
|
||||
jest.mock('umi-plugin-locale');
|
||||
|
||||
describe('Page: index', () => {
|
||||
it('Render correctly', () => {
|
||||
const wrapper: ReactTestRenderer = renderer.create(<Index />);
|
||||
expect(wrapper.root.children.length).toBe(1);
|
||||
const outerLayer = wrapper.root.children[0] as ReactTestInstance;
|
||||
expect(outerLayer.type).toBe('div');
|
||||
expect(outerLayer.children.length).toBe(2);
|
||||
const getStartLink = outerLayer.findAllByProps({
|
||||
href: 'https://umijs.org/guide/getting-started.html',
|
||||
}) as ReactTestInstance[];
|
||||
expect(getStartLink.length).toBe(1);
|
||||
expect(getStartLink[0].children).toMatchObject(['Mock text']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user