import * as React from 'react';
import expect from 'expect';
import { render, screen } from '@testing-library/react';
import { createMemoryHistory } from 'history';
import { CoreAdminContext } from './CoreAdminContext';
import { Resource } from './Resource';
import { Route } from 'react-router';
const PostList = () =>
PostList
;
const PostEdit = () => PostEdit
;
const PostCreate = () => PostCreate
;
const PostShow = () => PostShow
;
const PostIcon = () => PostIcon
;
const PostCustomRoute = () => PostCustomRoute
;
const resource = {
name: 'posts',
options: { foo: 'bar' },
list: PostList,
edit: PostEdit,
create: PostCreate,
show: PostShow,
icon: PostIcon,
children: } />,
};
describe('', () => {
it('renders resource routes by default', () => {
const history = createMemoryHistory();
render(
);
// Resource does not declare a route matching its name, it only renders its child routes
// so we don't need to navigate to a path matching its name
history.push('/');
expect(screen.getByText('PostList')).not.toBeNull();
history.push('/123');
expect(screen.getByText('PostEdit')).not.toBeNull();
history.push('/123/show');
expect(screen.getByText('PostShow')).not.toBeNull();
history.push('/create');
expect(screen.getByText('PostCreate')).not.toBeNull();
history.push('/customroute');
expect(screen.getByText('PostCustomRoute')).not.toBeNull();
});
});