import * as React from 'react';
import { useGetRecordId } from './useGetRecordId';
import { render, screen } from '@testing-library/react';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { RecordContextProvider } from '..';
describe('useGetRecordId', () => {
const UseGetRecordId = (props: any) => {
const recordId = useGetRecordId(props.id);
return
{recordId}
;
};
it('should return the record id it received in options', () => {
render();
expect(screen.queryByText('abc')).not.toBeNull();
});
it('should return the record id it received in options even if it is falsy', () => {
render();
expect(screen.queryByText('0')).not.toBeNull();
});
it('should return the record id it received through the record context', () => {
render(
);
expect(screen.queryByText('abc')).not.toBeNull();
});
it('should return the record id it received through the record context even if it is falsy', () => {
render(
);
expect(screen.queryByText('0')).not.toBeNull();
});
it('should return the record id parsed from the location', () => {
render(
} />
);
expect(screen.queryByText('abc')).not.toBeNull();
});
it('should return the record id parsed from the location even if it is falsy', () => {
render(
} />
);
expect(screen.queryByText('0')).not.toBeNull();
});
});