usePageContext.ts 756 B

123456789101112131415161718192021222324
  1. import {usePage, createPageContext} from '@hooks';
  2. import {renderHook} from '@testing-library/react';
  3. import {PAGE_SIZE_LIST} from '@utils';
  4. describe('usePageContext', function() {
  5. it('usePage, createContext 类型正确', function() {
  6. expect(usePage).toBeDefined();
  7. expect(createPageContext).toBeDefined();
  8. expect(usePage).toBeInstanceOf(Function);
  9. expect(createPageContext).toBeInstanceOf(Function);
  10. });
  11. it('usePage 返回值正确', function() {
  12. const {result} = renderHook(function() {
  13. const context = createPageContext();
  14. return usePage(context);
  15. });
  16. expect(result.current[0]).toEqual({page: 1, pageSize: Number(PAGE_SIZE_LIST[1])});
  17. expect(result.current[1]).toBeInstanceOf(Function);
  18. });
  19. });