-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Merge branch 'dev' of https://github.com/GDSC-Hongik/wow-class …
…into feature/layout
- Loading branch information
Showing
13 changed files
with
1,812 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Auto Assign | ||
|
||
on: | ||
pull_request: | ||
types: [opened, ready_for_review, converted_to_draft] | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
assign_pull_request: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request' | ||
steps: | ||
- uses: hkusu/review-assign-action@v1 | ||
with: | ||
assignees: ${{ github.actor }} | ||
|
||
auto_assign_issue: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'issues' | ||
permissions: | ||
issues: write | ||
steps: | ||
- name: "Auto-assign issue" | ||
uses: pozil/auto-assign-issue@v2 | ||
with: | ||
assignees: ${{ github.actor }} |
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,40 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
pull_request: | ||
types: [opened, ready_for_review, converted_to_draft] | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ vars.TURBO_TEAM }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js 20.x | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 20.x | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v3 | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Run build | ||
run: pnpm run build |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** @type {import("eslint").Linter.Config} */ | ||
module.exports = { | ||
root: true, | ||
extends: ["@wow-class/eslint-config/basic.js"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: true, | ||
ecmaVersion: 2020, | ||
sourceType: "module", | ||
}, | ||
}; |
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,10 @@ | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
setupFiles: ["<rootDir>/jest.setup.ts"], | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx"], | ||
transform: { | ||
"^.+\\.ts?$": "ts-jest", | ||
}, | ||
testMatch: ["<rootDir>/**/*.(test|spec).ts"], | ||
}; |
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,3 @@ | ||
import fetchMock from "jest-fetch-mock"; | ||
|
||
fetchMock.enableMocks(); |
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,15 @@ | ||
{ | ||
"name": "@wow-class/utils", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.5.12", | ||
"jest": "^29.7.0", | ||
"jest-fetch-mock": "^3.0.3", | ||
"ts-jest": "^29.2.4", | ||
"@wow-class/typescript-config": "workspace:*" | ||
} | ||
} |
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,126 @@ | ||
import fetchMock from "jest-fetch-mock"; | ||
|
||
import { fetcher } from "./fetcher"; | ||
|
||
describe("Fetcher", () => { | ||
beforeEach(() => { | ||
fetchMock.resetMocks(); | ||
}); | ||
|
||
it("should set the baseURL correctly", () => { | ||
fetcher.setBaseUrl("https://api.example.com"); | ||
|
||
expect(fetcher["baseUrl"]).toBe("https://api.example.com"); | ||
}); | ||
|
||
it("should set default headers correctly", () => { | ||
fetcher.setDefaultHeaders({ Authorization: "Bearer test-token" }); | ||
|
||
expect(fetcher["defaultHeaders"]).toEqual({ | ||
Authorization: "Bearer test-token", | ||
}); | ||
}); | ||
|
||
it("should make a GET request with the correct headers and URL", async () => { | ||
fetchMock.mockResponseOnce(JSON.stringify({ success: true })); | ||
fetcher.setBaseUrl("https://api.example.com"); | ||
fetcher.setDefaultHeaders({ | ||
"Content-Type": "application/json", | ||
Authorization: "Bearer test-token", | ||
}); | ||
|
||
const response = await fetcher.get("/test-endpoint"); | ||
|
||
expect(fetchMock).toHaveBeenCalledWith( | ||
"https://api.example.com/test-endpoint", | ||
{ | ||
method: "GET", | ||
headers: { | ||
Authorization: "Bearer test-token", | ||
"Content-Type": "application/json", | ||
}, | ||
} | ||
); | ||
const jsonData = JSON.parse(response.data); | ||
expect(jsonData).toEqual({ success: true }); | ||
}); | ||
|
||
it("should make a GET request with query parameters", async () => { | ||
fetchMock.mockResponseOnce(JSON.stringify({ success: true })); | ||
fetcher.setBaseUrl("https://api.example.com"); | ||
fetcher.setDefaultHeaders({ | ||
"Content-Type": "application/json", | ||
Authorization: "Bearer test-token", | ||
}); | ||
|
||
const params = { key1: "value1", key2: "value2" }; | ||
const response = await fetcher.get("/test-endpoint", {}, params); | ||
|
||
expect(fetchMock).toHaveBeenCalledWith( | ||
"https://api.example.com/test-endpoint?key1=value1&key2=value2", | ||
{ | ||
method: "GET", | ||
headers: { | ||
Authorization: "Bearer test-token", | ||
"Content-Type": "application/json", | ||
}, | ||
} | ||
); | ||
const jsonData = JSON.parse(response.data); | ||
expect(jsonData).toEqual({ success: true }); | ||
}); | ||
|
||
it("should make a POST request with the correct headers and URL and body", async () => { | ||
fetchMock.mockResponseOnce(JSON.stringify({ success: true })); | ||
fetcher.setBaseUrl("https://api.example.com"); | ||
fetcher.setDefaultHeaders({ | ||
"Content-Type": "application/json", | ||
Authorization: "Bearer test-token", | ||
}); | ||
|
||
const response = await fetcher.post("/test-endpoint", { foo: "bar" }); | ||
|
||
expect(fetchMock).toHaveBeenCalledWith( | ||
"https://api.example.com/test-endpoint", | ||
{ | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: "Bearer test-token", | ||
}, | ||
body: JSON.stringify({ foo: "bar" }), | ||
} | ||
); | ||
const jsonData = JSON.parse(response.data); | ||
expect(jsonData).toEqual({ success: true }); | ||
}); | ||
|
||
it("should handle plain text responses", async () => { | ||
fetchMock.mockResponseOnce("plain text response", { | ||
headers: { "Content-Type": "text/plain" }, | ||
}); | ||
fetcher.setBaseUrl("https://api.example.com"); | ||
|
||
const response = await fetcher.get("/test-endpoint"); | ||
expect(response.data).toBe("plain text response"); | ||
}); | ||
|
||
it("should handle HTTP errors correctly", async () => { | ||
fetchMock.mockResponseOnce("Not Found", { status: 404 }); | ||
fetcher.setBaseUrl("https://api.example.com"); | ||
fetcher.setDefaultHeaders({ | ||
"Content-Type": "application/json", | ||
Authorization: "Bearer test-token", | ||
}); | ||
|
||
try { | ||
await fetcher.get("/test-endpoint"); | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(Error); | ||
expect((error as any).response).toBeInstanceOf(Response); | ||
expect((error as any).response.status).toBe(404); | ||
expect((error as any).responseText).toBe("Not Found"); | ||
expect((error as any).message).toBe("HTTP Error: 404 Not Found"); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.