Status.spec.tsx 861 B

123456789101112131415161718192021222324252627282930313233
  1. import Status from '../../status/Status';
  2. import { LOADING_STATE } from '@/consts';
  3. import { render, screen } from '@testing-library/react';
  4. import { vi } from 'vitest';
  5. vi.mock('@material-ui/core/styles/makeStyles', () => {
  6. return () => () => ({});
  7. });
  8. vi.mock('react-i18next', () => {
  9. return {
  10. useTranslation: () => {
  11. return {
  12. t: () => {
  13. return {
  14. loaded: 'loaded',
  15. unloaded: 'unloaded',
  16. error: 'error',
  17. };
  18. },
  19. };
  20. },
  21. };
  22. });
  23. describe('Test Status', () => {
  24. it('Test props status', () => {
  25. render(<Status status={LOADING_STATE.LOADED} />);
  26. expect(screen.queryByText('loaded')?.textContent).toEqual('loaded');
  27. render(<Status status={LOADING_STATE.UNLOADED} />);
  28. expect(screen.queryByText('unloaded')?.textContent).toEqual('unloaded');
  29. });
  30. });