2021-02-28 12:36:56 +03:00
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import { Mock } from 'ts-mockery';
|
2021-03-14 14:49:12 +03:00
|
|
|
import { OrphanVisits as createOrphanVisits } from '../../src/visits/OrphanVisits';
|
2021-02-28 12:36:56 +03:00
|
|
|
import { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
|
|
|
|
import { VisitsInfo } from '../../src/visits/types';
|
|
|
|
import VisitsStats from '../../src/visits/VisitsStats';
|
|
|
|
import { OrphanVisitsHeader } from '../../src/visits/OrphanVisitsHeader';
|
2021-03-06 18:54:43 +03:00
|
|
|
import { Settings } from '../../src/settings/reducers/settings';
|
2022-03-13 20:56:42 +03:00
|
|
|
import { ReportExporter } from '../../src/common/services/ReportExporter';
|
2021-06-13 12:54:51 +03:00
|
|
|
import { SelectedServer } from '../../src/servers/data';
|
2021-02-28 12:36:56 +03:00
|
|
|
|
2022-02-08 00:17:57 +03:00
|
|
|
jest.mock('react-router-dom', () => ({
|
|
|
|
...jest.requireActual('react-router-dom'),
|
|
|
|
useNavigate: jest.fn().mockReturnValue(jest.fn()),
|
|
|
|
useParams: jest.fn().mockReturnValue({}),
|
|
|
|
}));
|
|
|
|
|
2021-02-28 12:36:56 +03:00
|
|
|
describe('<OrphanVisits />', () => {
|
|
|
|
it('wraps visits stats and header', () => {
|
|
|
|
const getOrphanVisits = jest.fn();
|
|
|
|
const cancelGetOrphanVisits = jest.fn();
|
|
|
|
const orphanVisits = Mock.all<VisitsInfo>();
|
2022-03-13 20:56:42 +03:00
|
|
|
const OrphanVisits = createOrphanVisits(Mock.all<ReportExporter>());
|
2021-02-28 12:36:56 +03:00
|
|
|
|
|
|
|
const wrapper = shallow(
|
|
|
|
<OrphanVisits
|
|
|
|
{...Mock.of<MercureBoundProps>({ mercureInfo: {} })}
|
|
|
|
getOrphanVisits={getOrphanVisits}
|
|
|
|
orphanVisits={orphanVisits}
|
|
|
|
cancelGetOrphanVisits={cancelGetOrphanVisits}
|
2021-03-06 18:54:43 +03:00
|
|
|
settings={Mock.all<Settings>()}
|
2021-06-13 12:54:51 +03:00
|
|
|
selectedServer={Mock.all<SelectedServer>()}
|
2021-02-28 12:36:56 +03:00
|
|
|
/>,
|
|
|
|
).dive();
|
|
|
|
const stats = wrapper.find(VisitsStats);
|
|
|
|
const header = wrapper.find(OrphanVisitsHeader);
|
|
|
|
|
|
|
|
expect(stats).toHaveLength(1);
|
|
|
|
expect(header).toHaveLength(1);
|
|
|
|
expect(stats.prop('cancelGetVisits')).toEqual(cancelGetOrphanVisits);
|
|
|
|
expect(stats.prop('visitsInfo')).toEqual(orphanVisits);
|
2022-02-05 18:37:01 +03:00
|
|
|
expect(stats.prop('isOrphanVisits')).toEqual(true);
|
2021-02-28 12:36:56 +03:00
|
|
|
expect(header.prop('orphanVisits')).toEqual(orphanVisits);
|
2022-02-08 00:17:57 +03:00
|
|
|
expect(header.prop('goBack')).toEqual(expect.any(Function));
|
2021-02-28 12:36:56 +03:00
|
|
|
});
|
|
|
|
});
|