From 9de4e64d0e88d5f941e078fd09d5256672844590 Mon Sep 17 00:00:00 2001 From: Revanth Kumar Date: Tue, 27 Apr 2021 16:11:53 -0500 Subject: [PATCH] Added initial test. --- .../Wishlist/__tests__/useWishlist.ce.spec.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 packages/peregrine/lib/talons/Wishlist/Wishlist/__tests__/useWishlist.ce.spec.js diff --git a/packages/peregrine/lib/talons/Wishlist/Wishlist/__tests__/useWishlist.ce.spec.js b/packages/peregrine/lib/talons/Wishlist/Wishlist/__tests__/useWishlist.ce.spec.js new file mode 100644 index 0000000000..b4af8c84a0 --- /dev/null +++ b/packages/peregrine/lib/talons/Wishlist/Wishlist/__tests__/useWishlist.ce.spec.js @@ -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 ; +}; + +const getTalonProps = props => { + const tree = createTestInstance(); + const { root } = tree; + const { talonProps } = root.findByType('i').props; + + const update = newProps => { + tree.update(); + + 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', () => { + +// })