Skip to content

Commit

Permalink
Added initial test.
Browse files Browse the repository at this point in the history
  • Loading branch information
revanth0212 committed Apr 27, 2021
1 parent f2a53b5 commit 9de4e64
Showing 1 changed file with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
// import { useMutation } from '@apollo/client';

import { useWishlist } from '../useWishlist.ce';
import createTestInstance from '../../../../util/createTestInstance';

jest.mock('@apollo/client', () =>
jest.fn().mockReturnValue([
jest.fn(),
{
loading: false,
called: false,
error: null
}
])
);

const defaultProps = {
item: {
sku: 'sku',
quantity: '1',
selected_options: 'selected options'
},
onWishlistUpdate: jest.fn(),
onWishlistUpdateError: jest.fn(),
updateWishlistToastProps: jest.fn()
};

const Component = props => {
const talonProps = useWishlist(props);

return <i talonProps={talonProps} />;
};

const getTalonProps = props => {
const tree = createTestInstance(<Component {...props} />);
const { root } = tree;
const { talonProps } = root.findByType('i').props;

const update = newProps => {
tree.update(<Component {...{ ...props, ...newProps }} />);

return root.findByType('i').props.talonProps;
};

return { talonProps, tree, update };
};

test('should return correct shape', () => {
const { talonProps } = getTalonProps(defaultProps);

expect(talonProps).toMatchSnapshot();
});

// test('handleAddToWishlist')

// test('should use necessary translations', () => {

// })

0 comments on commit 9de4e64

Please sign in to comment.