Skip to content

Instantly share code, notes, and snippets.

@BrianJenney
Last active August 9, 2021 16:10
Show Gist options
  • Save BrianJenney/841db219461eb06018bfd11065fe0841 to your computer and use it in GitHub Desktop.
Save BrianJenney/841db219461eb06018bfd11065fe0841 to your computer and use it in GitHub Desktop.
import React from 'react';
import { renderWithRedux, createReduxStore } from './tests/testHelpers';
import Cart from './Cart';
describe('Cart', () => {
it('displays the monetary value of the cart items', () => {
const cart = {
items: [
{
variant_name: 'Water Jug',
quantity: 1,
unit_price: 5.99,
discount_price: 5.99
}
};
const store = createReduxStore({ cart });
store.dispatch = dispatchStub;
store.subscribe = jest.fn();
const { getByText } = renderWithRedux(<CartDrawer />, { store });
expect(getByText('$5.99')).beTruthy();
// our cart inspects the redux store to find a customer name - the default is Cool Dude 😎
expect(getByText('Hello Cool Dude')).beTruthy();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment