Skip to content

Commit

Permalink
fix: library items
Browse files Browse the repository at this point in the history
  • Loading branch information
linspw committed Mar 21, 2024
1 parent 39a352e commit a71f067
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 247 deletions.
File renamed without changes.
34 changes: 0 additions & 34 deletions configs/project/rules-config.js

This file was deleted.

14 changes: 0 additions & 14 deletions configs/storybook/default-theme.js

This file was deleted.

66 changes: 0 additions & 66 deletions configs/storybook/helper.js

This file was deleted.

4 changes: 0 additions & 4 deletions configs/storybook/logo.svg

This file was deleted.

36 changes: 0 additions & 36 deletions configs/storybook/main.js

This file was deleted.

6 changes: 0 additions & 6 deletions configs/storybook/manager.js

This file was deleted.

16 changes: 0 additions & 16 deletions configs/storybook/preview-head.html

This file was deleted.

25 changes: 0 additions & 25 deletions configs/storybook/preview.js

This file was deleted.

9 changes: 9 additions & 0 deletions configs/tests/__snapshots__/lib.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Lib Test > when builded > attach plugin correctly 1`] = `
"<button class="h-button h-button--color-default h-button--size-small h-button--variant-contained" data-testid="example">
<!---->
<!----><span class="h-button__text">Event</span>
<!---->
</button>"
`;
46 changes: 0 additions & 46 deletions configs/tests/lib.test.skip.js

This file was deleted.

46 changes: 46 additions & 0 deletions configs/tests/lib.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { render, screen, fireEvent } from "@testing-library/vue";
import { describe, it, expect, vi } from "vitest";
// eslint-disable-next-line import/extensions
import * as Library from "../../dist/lib/experiment-ui.umd.js";

describe("Lib Test", () => {
it("builded with correct objects", () => {
expect(Library).toHaveProperty("ExperimentUI");
expect(Library).toHaveProperty("ExperimentUIComponents");
// const { html } = render(Library);
// expect(html()).toMatchSnapshot();
});

describe("when builded", () => {
it("attach plugin correctly", async () => {
const warn = vi.spyOn(console, "warn");
const error = vi.spyOn(console, "error");
const root = document.createElement("div");
root.setAttribute("data-app", "true");
const handleClick = vi.fn();
const exampleOfComponent = {
template:
'<h-button data-testid="example" @click="onClick">Event</h-button>',
methods: {
onClick: handleClick,
},
};

const vueInstanceConfig = {
global: {
plugins: [Library.ExperimentUI],
},
container: document.body.appendChild(root),
};

const { html } = render(exampleOfComponent, vueInstanceConfig);

expect(warn).not.toBeCalled();
expect(error).not.toBeCalled();
expect(html()).toMatchSnapshot();
await fireEvent.click(screen.getByTestId("example"));
expect(handleClick).toBeCalled();
// expect(window.getComputedStyle(screen.getByTestId('example'))).toHaveProperty('background-color: blue');
});
});
});

0 comments on commit a71f067

Please sign in to comment.