-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
706 additions
and
703 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }, | ||
], | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
}, | ||
}; |
Oops, something went wrong.