Skip to content

Commit

Permalink
fix: code format in __test__
Browse files Browse the repository at this point in the history
  • Loading branch information
si3nloong committed Jan 23, 2022
1 parent 13bd8e9 commit b3db326
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 29 deletions.
2 changes: 1 addition & 1 deletion components/docker/__test__/Docker.spec.ts
Expand Up @@ -54,5 +54,5 @@ describe("Docker", () => {
await fireEvent.click(container.querySelector(".resp-docker__overlay") as Element);
//test if closed
expect(docker.classList).toContain("resp-docker--close");
})
});
});
25 changes: 14 additions & 11 deletions components/dropdown/__test__/Dropdown.spec.ts
@@ -1,4 +1,4 @@
import {render, fireEvent} from "@testing-library/svelte";
import { render, fireEvent } from "@testing-library/svelte";
import Dropdown from "../src/Dropdown.svelte";
import SlotTest from "../../../test/slot/SlotTest.svelte";

Expand Down Expand Up @@ -54,12 +54,14 @@ describe("Dropdown", () => {

describe("click dropdown", () => {
it("should render with click", () => {
const result = render(Dropdown, {propsClick});
const result = render(Dropdown, { propsClick });
expect(() => result).not.toThrow();
});

it("slot test", () => {
const result = render(SlotTest, {props: {component: Dropdown, props: propsClick}});
const result = render(SlotTest, {
props: { component: Dropdown, props: propsClick }
});
expect(() => result).not.toThrow();
});

Expand All @@ -71,32 +73,33 @@ describe("Dropdown", () => {
// it("should perform correct action", () => {

// });

});

describe("hover dropdown", () => {
it("should render with hover", () => {
const result = render(Dropdown, {propsHover});
const result = render(Dropdown, { propsHover });
expect(() => result).not.toThrow();
});

it("slot test", () => {
const result = render(SlotTest, {props: {component: Dropdown, props: propsHover}});
const result = render(SlotTest, {
props: { component: Dropdown, props: propsHover }
});
expect(() => result).not.toThrow();
});

});

describe("hover context", () => {
it("should render with context", () => {
const result = render(Dropdown, {propsContext});
const result = render(Dropdown, { propsContext });
expect(() => result).not.toThrow();
});

it("slot test", () => {
const result = render(SlotTest, {props: {component: Dropdown, props: propsContext}});
const result = render(SlotTest, {
props: { component: Dropdown, props: propsContext }
});
expect(() => result).not.toThrow();
});

});
})
});
16 changes: 8 additions & 8 deletions components/ellipsis/__test__/Ellipsis.spec.ts
@@ -1,6 +1,6 @@
import {render, fireEvent} from '@testing-library/svelte';
import Ellipsis from '../src/Ellipsis.svelte';
import SlotTest from '../../../test/slot/SlotTest.svelte';
import { render, fireEvent } from "@testing-library/svelte";
import Ellipsis from "../src/Ellipsis.svelte";
import SlotTest from "../../../test/slot/SlotTest.svelte";

describe("Ellipsis", () => {
const props = {
Expand All @@ -11,22 +11,22 @@ describe("Ellipsis", () => {
};

it("should render", () => {
const result = render(Ellipsis, {props});
const result = render(Ellipsis, { props });
expect(() => result).not.toThrow();
});

it("should render slots", () => {
const result = render(SlotTest, {props: {component: Ellipsis, props}});
const result = render(SlotTest, { props: { component: Ellipsis, props } });
expect(() => result).not.toThrow();
});

it("click event", async () => {
const {component, container} = render(Ellipsis, {props});
const { component, container } = render(Ellipsis, { props });

const fn = jest.fn();
component.$on('click', fn);
component.$on("click", fn);
await fireEvent.click(container.querySelector("#id") as HTMLElement);

expect(fn).toHaveBeenCalled();
});
});
});
6 changes: 3 additions & 3 deletions components/fab/__test__/FloatingActionButton.spec.ts
Expand Up @@ -16,7 +16,7 @@ describe("FAB", () => {
});

it("props test", () => {
const {container} = render(FloatingActionButton, { props });
const { container } = render(FloatingActionButton, { props });
const fab = container.querySelector("." + props.class) as HTMLElement;

expect(fab.id).toEqual(props.id); //test id
Expand All @@ -26,11 +26,11 @@ describe("FAB", () => {
});

it("test click event", async () => {
const {container, component} = render(FloatingActionButton, { props });
const { container, component } = render(FloatingActionButton, { props });
const fab = container.querySelector("." + props.class) as HTMLElement;

const mock = jest.fn(); //test function
component.$on('click', mock); //set function onclick
component.$on("click", mock); //set function onclick

//click
await fireEvent.click(fab);
Expand Down
16 changes: 10 additions & 6 deletions components/hscroll/__test__/HScroll.spec.ts
@@ -1,4 +1,4 @@
import {render, fireEvent} from '@testing-library/svelte';
import { render, fireEvent } from "@testing-library/svelte";
import HScroll from "../src/HScroll.svelte";
import SlotTest from "../../../test/slot/SlotTest.svelte";

Expand All @@ -23,7 +23,7 @@ describe("Horizontal Scroll", () => {
});

it("should have correct props", () => {
const {container} = render(HScroll, { props });
const { container } = render(HScroll, { props });
const hScroll = container.querySelector("." + props.class) as HTMLElement;

expect(hScroll.id).toEqual(props.id); //id test
Expand All @@ -32,12 +32,16 @@ describe("Horizontal Scroll", () => {
});

it("click test", async () => {
const {container} = render(HScroll, { props });
const { container } = render(HScroll, { props });
const hScroll = container.querySelector(".resp-scroll") as HTMLElement;

//buttons
const prev = hScroll.querySelector(".resp-scroll__prev-icon > .resp-scroll__icon") as HTMLElement;
const next = hScroll.querySelector(".resp-scroll__next-icon > .resp-scroll__icon") as HTMLElement;
const prev = hScroll.querySelector(
".resp-scroll__prev-icon > .resp-scroll__icon"
) as HTMLElement;
const next = hScroll.querySelector(
".resp-scroll__next-icon > .resp-scroll__icon"
) as HTMLElement;

//mock fns
const mockPrev = jest.fn(() => {
Expand All @@ -58,4 +62,4 @@ describe("Horizontal Scroll", () => {
await fireEvent.click(next);
expect(mockNext).toHaveBeenCalled();
});
});
});

0 comments on commit b3db326

Please sign in to comment.