| 123456789101112131415161718192021222324 |
- import {usePage, createPageContext} from '@hooks';
- import {renderHook} from '@testing-library/react';
- import {PAGE_SIZE_LIST} from '@utils';
- describe('usePageContext', function() {
- it('usePage, createContext 类型正确', function() {
- expect(usePage).toBeDefined();
- expect(createPageContext).toBeDefined();
- expect(usePage).toBeInstanceOf(Function);
- expect(createPageContext).toBeInstanceOf(Function);
- });
- it('usePage 返回值正确', function() {
- const {result} = renderHook(function() {
- const context = createPageContext();
- return usePage(context);
- });
- expect(result.current[0]).toEqual({page: 1, pageSize: Number(PAGE_SIZE_LIST[1])});
- expect(result.current[1]).toBeInstanceOf(Function);
- });
- });
|