import 'jest';
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import BR, { BlueRainProvider } from '@blueeast/bluerain-os';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

import AppCard from '../AppCard';

BR.Components.set('View', () => <div>View</div>);
BR.Components.set('Text', () => <div>Text</div>);
BR.Components.set('Link', () => <div>Link</div>);
BR.Apps.getIconElement = jest.fn();


// it('renders correctly Card', () => {
// 	const tree = renderer.create(
// 		<BlueRainProvider>
// 			<AppCard />
// 		</BlueRainProvider>
// 	).toJSON();
// 	expect(tree).toMatchSnapshot();
// });

// test('AppCard renders correctly with size prop ', () => {
// 	const wrapper = shallow(
// 		<BlueRainProvider>
// 			<AppCard size={100} />
// 		</BlueRainProvider>
// 	);
// 	const props: any = wrapper.instance().props;
// 	expect(props.children.props.size).toEqual(100);
// });

// it('renders correctly Card', () => {
// 	const tree = renderer.create(
// 		<BlueRainProvider>
// 			<AppCard size={100} />
// 		</BlueRainProvider>
// 	).toJSON();
// 	expect(tree).toMatchSnapshot();
// });

// test('AppCard renders with size & name', () => {
// 	const wrapper = shallow(
// 		<BlueRainProvider>
// 			<AppCard size={160} name={'Card1'} />
// 		</BlueRainProvider>
// 	);
// 	const props: any = wrapper.instance().props;
// 	expect(props.children.props.name).toEqual('Card1');
// 	expect(props.children.props.size).toEqual(160);
// });

// it('AppCard renders correctly with size & name', () => {
// 	const tree = renderer.create(
// 		<BlueRainProvider>
// 			<AppCard size={160} name={'Card1'} />
// 		</BlueRainProvider>
// 	).toJSON();
// 	expect(tree).toMatchSnapshot();
// });

test('AppCard renders with size, name & link', () => {
	const wrapper = shallow(
		<BlueRainProvider>
			<AppCard size={160} name={'Card1'} link={'/'} />
		</BlueRainProvider>
	);
	const props: any = wrapper.instance().props;
	expect(props.children.props.name).toEqual('Card1');
	expect(props.children.props.size).toEqual(160);
	expect(props.children.props.link).toEqual('/');
});

it('AppCard renders correctly with size, name & link', () => {
	const tree = renderer.create(
		<BlueRainProvider>
			<AppCard size={160} name={'Card1'} link={'/'} />
		</BlueRainProvider>
	).toJSON();
	expect(tree).toMatchSnapshot();
});

test('AppCard renders with all props', () => {
	const wrapper = shallow(
		<BlueRainProvider>
			<AppCard size={160} name={'Card1'} link={'/'} slug={'Hello'} />
		</BlueRainProvider>
	);
	const props: any = wrapper.instance().props;
	expect(props.children.props.size).toEqual(160);
	expect(props.children.props.name).toEqual('Card1');
	expect(props.children.props.link).toEqual('/');
	expect(props.children.props.slug).toEqual('Hello');
});

it('AppCard renders correctly with all props', () => {
	const tree = renderer.create(
		<BlueRainProvider>
			<AppCard size={160} name={'Card1'} link={'/'} slug={'Hello'} />
		</BlueRainProvider>
	).toJSON();
	expect(tree).toMatchSnapshot();
});
