Skip to content

Commit

Permalink
💚 use space in indent style
Browse files Browse the repository at this point in the history
  • Loading branch information
nus3 committed Apr 16, 2024
1 parent 2269918 commit 14053b2
Show file tree
Hide file tree
Showing 36 changed files with 706 additions and 703 deletions.
50 changes: 25 additions & 25 deletions apps/react-vitest/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ import { dirname, join } from "node:path";
import type { StorybookConfig } from "@storybook/react-vite";

function getAbsolutePath(value: string) {
return dirname(require.resolve(join(value, "package.json")));
return dirname(require.resolve(join(value, "package.json")));
}

const config: StorybookConfig = {
framework: {
// HACK: "@storybook/react-vite"しか許可されていない部分をstringも許可するように
// @ts-expect-error
name: getAbsolutePath("@storybook/react-vite"),
options: {},
},

stories: ["../src/components/**/*.stories.@(js|jsx|ts|tsx)"],

addons: [
getAbsolutePath("@storybook/addon-links"),
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@storybook/addon-interactions"),
],

staticDirs: ["../public"],

async viteFinal(config) {
return config;
},

docs: {
autodocs: true,
},
framework: {
// HACK: "@storybook/react-vite"しか許可されていない部分をstringも許可するように
// @ts-expect-error
name: getAbsolutePath("@storybook/react-vite"),
options: {},
},

stories: ["../src/components/**/*.stories.@(js|jsx|ts|tsx)"],

addons: [
getAbsolutePath("@storybook/addon-links"),
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@storybook/addon-interactions"),
],

staticDirs: ["../public"],

async viteFinal(config) {
return config;
},

docs: {
autodocs: true,
},
};

export default config;
34 changes: 17 additions & 17 deletions apps/react-vitest/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export const parameters = {
backgrounds: {
default: "gray",
values: [
{
name: "white",
value: "#FFFFFF",
},
{
name: "gray",
value: "#D4D7D7",
},
{
name: "black",
value: "#000000",
},
],
},
backgrounds: {
default: "gray",
values: [
{
name: "white",
value: "#FFFFFF",
},
{
name: "gray",
value: "#D4D7D7",
},
{
name: "black",
value: "#000000",
},
],
},
};
23 changes: 13 additions & 10 deletions apps/react-vitest/biome.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.0/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
"$schema": "https://biomejs.dev/schemas/1.7.0/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"indentStyle": "space"
}
}
96 changes: 48 additions & 48 deletions apps/react-vitest/package.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
{
"name": "react-vitest",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"fix": "biome check --apply .",
"fix:unsafe": "biome check --apply-unsafe .",
"lint": "biome lint .",
"test": "vitest",
"test:ui": "vitest --ui",
"type-check": "tsc --noEmit",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test-storybook": "test-storybook"
},
"dependencies": {
"clsx": "1.1.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@biomejs/biome": "1.7.0",
"@storybook/addon-docs": "8.0.8",
"@storybook/addon-essentials": "8.0.8",
"@storybook/addon-interactions": "8.0.8",
"@storybook/addon-links": "8.0.8",
"@storybook/react": "8.0.8",
"@storybook/react-vite": "8.0.8",
"@storybook/test": "8.0.8",
"@storybook/test-runner": "0.17.0",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "15.0.2",
"@testing-library/user-event": "14.5.2",
"@types/react": "18.2.25",
"@types/react-dom": "18.2.25",
"@vitejs/plugin-react": "4.2.1",
"@vitest/ui": "1.5.0",
"jsdom": "24.0.0",
"msw": "2.2.13",
"storybook": "8.0.8",
"typescript": "5.2.2",
"vite": "5.2.8",
"vitest": "1.5.0",
"whatwg-fetch": "3.6.2"
}
"name": "react-vitest",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"fix": "biome check --apply .",
"fix:unsafe": "biome check --apply-unsafe .",
"lint": "biome lint .",
"test": "vitest",
"test:ui": "vitest --ui",
"type-check": "tsc --noEmit",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test-storybook": "test-storybook"
},
"dependencies": {
"clsx": "1.1.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@biomejs/biome": "1.7.0",
"@storybook/addon-docs": "8.0.8",
"@storybook/addon-essentials": "8.0.8",
"@storybook/addon-interactions": "8.0.8",
"@storybook/addon-links": "8.0.8",
"@storybook/react": "8.0.8",
"@storybook/react-vite": "8.0.8",
"@storybook/test": "8.0.8",
"@storybook/test-runner": "0.17.0",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "15.0.2",
"@testing-library/user-event": "14.5.2",
"@types/react": "18.2.25",
"@types/react-dom": "18.2.25",
"@vitejs/plugin-react": "4.2.1",
"@vitest/ui": "1.5.0",
"jsdom": "24.0.0",
"msw": "2.2.13",
"storybook": "8.0.8",
"typescript": "5.2.2",
"vite": "5.2.8",
"vitest": "1.5.0",
"whatwg-fetch": "3.6.2"
}
}
10 changes: 5 additions & 5 deletions apps/react-vitest/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import type { FC } from "react";
import styles from "./App.module.css";

export const App: FC = () => {
return (
<section className={styles.wrap}>
<h1 className={styles.title}>React Test Examples</h1>
</section>
);
return (
<section className={styles.wrap}>
<h1 className={styles.title}>React Test Examples</h1>
</section>
);
};
16 changes: 8 additions & 8 deletions apps/react-vitest/src/api/__mocks__/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { vi } from "vitest";
import type * as exampleApi from "../example";

export const getExamples: typeof exampleApi.getExamples = vi.fn(async () => {
const res: exampleApi.GetExamplesResponse = await {
examples: [
{ id: "1", name: "nus1" },
{ id: "2", name: "nus2" },
{ id: "3", name: "nus3" },
],
};
return res;
const res: exampleApi.GetExamplesResponse = await {
examples: [
{ id: "1", name: "nus1" },
{ id: "2", name: "nus2" },
{ id: "3", name: "nus3" },
],
};
return res;
});
64 changes: 32 additions & 32 deletions apps/react-vitest/src/api/example.test.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
import { http, HttpResponse } from "msw";
import { setupServer } from "msw/node";
import {
afterAll,
afterEach,
beforeAll,
describe,
expect,
test,
vi,
afterAll,
afterEach,
beforeAll,
describe,
expect,
test,
vi,
} from "vitest";

import { getExamples } from "./example";

vi.unmock("./example");

const mockHandlers = [
http.get("/examples", () => {
return HttpResponse.json(
{
examples: [
{ id: "1", name: "nus1" },
{ id: "2", name: "nus2" },
{ id: "3", name: "nus3" },
],
},
{ status: 200 },
);
}),
http.get("/examples", () => {
return HttpResponse.json(
{
examples: [
{ id: "1", name: "nus1" },
{ id: "2", name: "nus2" },
{ id: "3", name: "nus3" },
],
},
{ status: 200 },
);
}),
];

const server = setupServer(...mockHandlers);

describe("/examples", () => {
beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());

test("should called get examples api", async () => {
const response = await getExamples();
expect(response).toStrictEqual({
examples: [
{ id: "1", name: "nus1" },
{ id: "2", name: "nus2" },
{ id: "3", name: "nus3" },
],
});
});
test("should called get examples api", async () => {
const response = await getExamples();
expect(response).toStrictEqual({
examples: [
{ id: "1", name: "nus1" },
{ id: "2", name: "nus2" },
{ id: "3", name: "nus3" },
],
});
});
});
16 changes: 8 additions & 8 deletions apps/react-vitest/src/api/example.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export type GetExamplesRequest = {
name: string;
name: string;
};

export type GetExamplesResponse = {
examples: Array<{ id: string; name: string }>;
examples: Array<{ id: string; name: string }>;
};

export const getExamples = async (params?: GetExamplesRequest) => {
const response = await fetch("/examples", {
method: "GET",
body: params && JSON.stringify({ name: params.name }),
});
const formattedResponse = await response.json();
return formattedResponse as GetExamplesResponse;
const response = await fetch("/examples", {
method: "GET",
body: params && JSON.stringify({ name: params.name }),
});
const formattedResponse = await response.json();
return formattedResponse as GetExamplesResponse;
};
12 changes: 6 additions & 6 deletions apps/react-vitest/src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { fn } from "@storybook/test";
import { Button } from "./Button";

import type { StoryObj, Meta } from "@storybook/react";
import type { Meta, StoryObj } from "@storybook/react";

const meta: Meta = {
component: Button,
component: Button,
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
children: "label",
onClick: fn(),
},
args: {
children: "label",
onClick: fn(),
},
};
Loading

0 comments on commit 14053b2

Please sign in to comment.