Skip to content

Commit

Permalink
test: 💍 remove modal test (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskaransarkaria authored Mar 16, 2024
1 parent e16fc74 commit 3fd384d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import AddToBasket from "$lib/components/AddToBasket/AddToBasket.svelte";
import SwipeImage from "$lib/components/SwipeImage/SwipeImage.svelte";
import { getImageFilename } from "$lib/utils/getImageFilename";
import Modal from "$lib/components/Modal/Modal.svelte";
import type { Product } from "$lib/types/product";
import { isAvifSupported } from "$lib/stores/isAvifSupported";
Expand Down Expand Up @@ -36,7 +35,6 @@
},
];
let showModal = false;
let clientWidth: number = 0;
</script>

Expand All @@ -47,10 +45,6 @@
class="mobile-img-container"
data-testid="mobile-img-container"
style:width={clientWidth ? clientWidth + "px" : "90vw"}
on:click={() => {
showModal = true;
window.scrollTo(0, 0);
}}
>
<SwipeImage imgArr={createImgArr(product)} />
</div>
Expand Down Expand Up @@ -78,14 +72,7 @@
{:else}
<div class="details-container">
<div class="desktop-left-container">
<div
class="desktop-img-container"
data-testid="desktop-img-container"
on:click={() => {
showModal = true;
window.scrollTo(0, 0);
}}
>
<div class="desktop-img-container" data-testid="desktop-img-container">
<SwipeImage imgArr={createImgArr(product)} />
</div>
</div>
Expand All @@ -108,11 +95,6 @@
</div>
</div>
{/if}
{#if showModal}
<Modal {isMobile} showFullScreen={true} bind:showModal>
<SwipeImage imgArr={createImgArr(product)} />
</Modal>
{/if}

<style>
h2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,6 @@ describe("GIVEN DetailedSingleProduct", () => {
isMobile: false,
productDescription: "some dummy description",
});

expect(
screen.queryByTestId("desktop-show-modal")
).not.toBeInTheDocument();
await userEvent.click(screen.getByTestId("desktop-img-container"));

expect(screen.getByTestId("desktop-show-modal")).toBeInTheDocument();
expect(screen.getByTestId("desktop-show-modal")).toBeVisible();
expect(screen.getByTestId("desktop-show-modal")).toHaveClass(
"desktop-show-modal"
);
});

it.skip("THEN close full screen", async () => {
render(DetailedSingleProduct, {
product: dummyProduct,
isMobile: false,
productDescription: "some dummy description",
});

expect(
screen.queryByTestId("desktop-show-modal")
).not.toBeInTheDocument();
await userEvent.click(screen.getByTestId("desktop-img-container"));

expect(screen.getByTestId("desktop-show-modal")).toBeInTheDocument();
expect(screen.getByTestId("desktop-show-modal")).toBeVisible();
expect(screen.getByTestId("desktop-show-modal")).toHaveClass(
"desktop-show-modal"
);

await userEvent.keyboard("Escape");
expect(
screen.queryByTestId("desktop-show-modal")
).not.toBeInTheDocument();
});

it("THEN display formatted product description", () => {
Expand Down Expand Up @@ -156,15 +121,6 @@ describe("GIVEN DetailedSingleProduct", () => {
isMobile: true,
productDescription: "some dummy description",
});

expect(screen.queryByTestId("mobile-show-modal")).not.toBeInTheDocument();
await userEvent.click(screen.getByTestId("mobile-img-container"));

expect(screen.getByTestId("mobile-show-modal")).toBeInTheDocument();
expect(screen.getByTestId("mobile-show-modal")).toBeVisible();
expect(screen.getByTestId("mobile-show-modal")).toHaveClass(
"mobile-show-modal"
);
});

it("THEN close MOBILE full screen", async () => {
Expand All @@ -173,18 +129,6 @@ describe("GIVEN DetailedSingleProduct", () => {
isMobile: true,
productDescription: "some dummy description",
});

expect(screen.queryByTestId("mobile-show-modal")).not.toBeInTheDocument();
await userEvent.click(screen.getByTestId("mobile-img-container"));

expect(screen.getByTestId("mobile-show-modal")).toBeInTheDocument();
expect(screen.getByTestId("mobile-show-modal")).toBeVisible();
expect(screen.getByTestId("mobile-show-modal")).toHaveClass(
"mobile-show-modal"
);

await userEvent.click(screen.getByTestId("mobile-close"));
expect(screen.queryByTestId("mobile-show-modal")).not.toBeInTheDocument();
});

it("THEN display formatted product description", () => {
Expand Down
2 changes: 0 additions & 2 deletions src/lib/components/SwipeImage/SwipeImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
{src}
{alt}
data-testid="swipe-img"
style:cursor={fullScreen ? null : "pointer"}
class={fullScreen ? "full-screen" : ""}
/>
<div class="custom-pagination-div" />
Expand All @@ -51,7 +50,6 @@
<img
src={imgArr[0].src}
alt={imgArr[0].alt}
style:cursor={fullScreen ? null : "pointer"}
on:error={() => {
if (imgArr[0].src != comingSoon) {
imgArr[0].src = comingSoon;
Expand Down

0 comments on commit 3fd384d

Please sign in to comment.