Skip to content

Commit

Permalink
chore: jest tests fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Oct 7, 2022
1 parent 52f305b commit e785472
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 98 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -22,6 +22,9 @@ jobs:
- name: Install dependencies
run: npm install

- name: Copy .env file
run: cp .env.dist .env

- name: Test all projects
run: npm test -- --coverage

Expand Down
11 changes: 0 additions & 11 deletions src/components/__snapshots__/grid.spec.js.snap

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/__snapshots__/rail.spec.js.snap

This file was deleted.

5 changes: 1 addition & 4 deletions src/components/cart-options/product-attributes.jsx
Expand Up @@ -21,10 +21,7 @@ function ProductAttributes({ variations, attributes, setVariation }) {
({ attributes: variationAttributes }) => (
variationAttributes?.nodes || []
)?.every(
({ value, label }) => {
console.log({ value, label }, selectedAttributes)
return selectedAttributes[label] === value;
},
({ value, label }) => selectedAttributes[label] === value,
),
);

Expand Down
Expand Up @@ -5,6 +5,7 @@ exports[`CheckoutButton should render successfully 1`] = `
<div>
<a
class="primary-button mx-6 py-3 w-full text-center text-xl mb-5"
href="http://example.com/checkout/checkout?session_id=t_470b1dc6f84165a355ebde33510e53&_wpnonce=629602a9cb"
>
<i
class="fa-solid fa-cash-register mr-5"
Expand Down
7 changes: 6 additions & 1 deletion src/components/cart/checkout-button.jsx
@@ -1,7 +1,12 @@
import { useSession } from '../session-provider';
import Spinner from '../spinner';

function CheckoutButton() {
const { pathToCheckout } = useSession();
const { pathToCheckout, fetchingCart } = useSession();
if (fetchingCart || !pathToCheckout) {
return <Spinner className="w-full py-3" />;
}

return (
<a
className="primary-button mx-6 py-3 w-full text-center text-xl mb-5"
Expand Down
7 changes: 4 additions & 3 deletions src/components/cart/checkout-button.spec.jsx
@@ -1,22 +1,23 @@
import React from 'react';
import '@testing-library/react/dont-cleanup-after-each';
import { render, cleanup } from '@testing-library/react';
import { render, cleanup, waitFor } from '@testing-library/react';

import ApolloMockProvider from '../../testing/apollo-mock-provider';
import SessionProvider from '../session-provider';
import CheckoutButton from './checkout-button';

describe('CheckoutButton', () => {
afterAll(() => cleanup());
const { baseElement } = render(
const { baseElement, getByText } = render(
<ApolloMockProvider>
<SessionProvider>
<CheckoutButton />
</SessionProvider>
</ApolloMockProvider>,
);

it('should render successfully', () => {
it('should render successfully', async () => {
await waitFor(() => expect(getByText(/Checkout/)).toBeTruthy());
expect(baseElement).toMatchSnapshot();
});
});
22 changes: 11 additions & 11 deletions src/components/product/__snapshots__/gallery.spec.jsx.snap
Expand Up @@ -37,7 +37,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_163026-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_163026-scaled.jpg"
width="undefined"
/>
</div>
Expand All @@ -57,7 +57,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_163004-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_163004-scaled.jpg"
width="undefined"
/>
</div>
Expand All @@ -77,7 +77,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_163026-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_163026-scaled.jpg"
width="undefined"
/>
</div>
Expand All @@ -97,7 +97,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_163401-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_163401-scaled.jpg"
width="undefined"
/>
</div>
Expand All @@ -117,7 +117,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_1634440-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_1634440-scaled.jpg"
width="undefined"
/>
</div>
Expand All @@ -137,7 +137,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_171640-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_171640-scaled.jpg"
width="undefined"
/>
</div>
Expand All @@ -157,7 +157,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_171658-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_171658-scaled.jpg"
width="undefined"
/>
</div>
Expand All @@ -177,7 +177,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_172700-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_172700-scaled.jpg"
width="undefined"
/>
</div>
Expand All @@ -197,7 +197,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_172729-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_172729-scaled.jpg"
width="undefined"
/>
</div>
Expand All @@ -217,7 +217,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_173018-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_173018-scaled.jpg"
width="undefined"
/>
</div>
Expand All @@ -237,7 +237,7 @@ exports[`ProductGallery should render successfully 1`] = `
class="relative object-contain max-h-[90vh] max-w-full w-full h-auto"
height="undefined"
layout="fill"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_1655550-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_1655550-scaled.jpg"
width="undefined"
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/shop/__snapshots__/item.spec.jsx.snap
Expand Up @@ -10,7 +10,7 @@ exports[`Item component renders successfully 1`] = `
<img
alt=""
class="max-w-full w-44"
src="https://superduper.axistaylor.com/app/uploads/sites/3/2022/08/20220805_163026-scaled.jpg"
src="https://example.com/app/uploads/sites/3/2022/08/20220805_163026-scaled.jpg"
/>
<div
class="inline-flex flex-col justify-center items-center shrink w-44 h-44"
Expand Down

0 comments on commit e785472

Please sign in to comment.