-
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
20 changed files
with
479 additions
and
115 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: check | ||
on: push | ||
jobs: | ||
eslint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v2 | ||
with: | ||
bun-version: latest | ||
- run: bun install --frozen-lockfile | ||
- run: bun run lint | ||
|
||
tsc: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v2 | ||
with: | ||
bun-version: latest | ||
- run: bun install --frozen-lockfile | ||
- run: bun run typecheck | ||
|
||
prettier: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v2 | ||
with: | ||
bun-version: latest | ||
- run: bun install --frozen-lockfile | ||
- run: bun run prettier --check . | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v2 | ||
with: | ||
bun-version: latest | ||
- run: bun install --frozen-lockfile | ||
- run: bun run test |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: reviewdog | ||
on: [pull_request] | ||
jobs: | ||
eslint: | ||
name: runner / eslint | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v2 | ||
with: | ||
bun-version: latest | ||
- run: bun install --frozen-lockfile | ||
- uses: reviewdog/action-eslint@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
reporter: github-pr-review # Change reporter. | ||
eslint_flags: "--ignore-path .gitignore ." |
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
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,3 +1,6 @@ | ||
export const hasId = <T>(obj: T): obj is Required<T> => { | ||
return (obj as any).id !== undefined; | ||
export type WithId<T extends { id?: unknown }> = T & | ||
Record<"id", NonNullable<T["id"]>>; | ||
|
||
export const hasId = <T extends { id?: unknown }>(obj: T): obj is WithId<T> => { | ||
return obj.id !== undefined; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { expect, test } from "vitest"; | ||
import { ItemWithId } from "./item"; | ||
import { OrderEntity } from "./order"; | ||
|
||
test("order total auto calc", () => { | ||
const order = OrderEntity.createNew(2024); | ||
expect(order.total).toBe(0); | ||
|
||
const items: ItemWithId[] = [ | ||
{ | ||
id: "1", | ||
name: "item1", | ||
price: 100, | ||
type: "hot", | ||
}, | ||
{ | ||
id: "2", | ||
name: "item2", | ||
price: 341, | ||
type: "ice", | ||
}, | ||
]; | ||
order.items.push(...items); | ||
expect(order.total).toBe(441); | ||
|
||
order.items.push({ | ||
id: "3", | ||
name: "item3", | ||
price: 100, | ||
type: "ore", | ||
}); | ||
expect(order.total).toBe(541); | ||
}); | ||
|
||
test("order beReady", () => { | ||
const order = OrderEntity.createNew(2024); | ||
expect(order.orderReady).toBe(false); | ||
|
||
order.beReady(); | ||
expect(order.orderReady).toBe(true); | ||
}); | ||
|
||
test("order beServed", () => { | ||
const order = OrderEntity.createNew(2024); | ||
expect(order.servedAt).toBe(null); | ||
|
||
order.beServed(); | ||
expect(order.servedAt).not.toBe(null); | ||
expect(order.servedAt).toBeInstanceOf(Date); | ||
}); |
Oops, something went wrong.