diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index b04ec333..f03a5e41 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -32,7 +32,19 @@ jobs: bun install --frozen-lockfile - name: Lint - run: bun lint + run: bun run lint --max-warnings=0 + formatt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + + - name: Bun Install + run: | + bun install --frozen-lockfile + + - name: Format + run: bun run format --check verify-open-api-doc: runs-on: ubuntu-latest diff --git a/.husky/pre-commit b/.husky/pre-commit index e640892e..78573e1c 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1,39 @@ -bun lint --fix \ No newline at end of file +# Restore stashed unstaged changes. On conflict, restore working tree and re-apply stash. +restore_stash() { + if git stash apply stash@{0} 2>/dev/null; then + git stash drop stash@{0} + else + git restore . + git stash pop + echo "⚠️ Lint/format fixes conflicted with unstaged changes; restored your working tree." + exit 1 + fi +} + +# Get staged .ts and .json files +staged=$(git diff --cached --name-only | grep -E '\.(ts|json)$' || true) + +if [ -n "$staged" ]; then + stash_used= + # Stash unstaged changes so lint/format only see staged content + if ! git diff --quiet; then + git stash push -m "pre-commit: unstaged changes" --keep-index + stash_used=1 + fi + + echo "$staged" | xargs bunx eslint --fix --max-warnings=0 || { [ -n "$stash_used" ] && restore_stash; exit 1; } + echo "$staged" | xargs bunx prettier --write + + # Fail if lint/format changed any of the files we ran on + diff=$(echo "$staged" | xargs git diff --name-only -- 2>/dev/null | sort -u) + if [ -n "$diff" ]; then + [ -n "$stash_used" ] && restore_stash + echo "🚨 Lint or format applied fixes. Stage them and commit again." + echo "$diff" | while read -r f; do + printf '\033[31m%s\033[0m\n' "$f" + done + exit 1 + fi + + [ -n "$stash_used" ] && restore_stash +fi diff --git a/bun.lockb b/bun.lockb index 8c44b5f6..a3fff7ae 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 73f5caec..301a1199 100644 --- a/package.json +++ b/package.json @@ -15,17 +15,18 @@ "scripts": { "prepare": "husky", "dev": "bun --watch ./src/index.ts", + "test": "bun test tests/", "typecheck": "tsc --noEmit", "lint": "eslint . --ext .ts,.json", - "format": "prettier '**/*.{ts,json}'", + "format": "bun prettier '**/*.{ts,json}' --write", "docs": "bun run ./open-api/generate.ts", "compile": "bun build --compile --sourcemap ./src/index.ts --outfile $1" }, "lint-staged": { "*.{ts,json}": [ - "eslint --fix" - ], - "*.js": "eslint --cache --fix" + "eslint --fix --max-warnings=0", + "prettier --write" + ] }, "devDependencies": { "@asteasolutions/zod-to-openapi": "^6.3.1", diff --git a/src/auth/admin.test.ts b/tests/auth/admin.test.ts similarity index 95% rename from src/auth/admin.test.ts rename to tests/auth/admin.test.ts index 9971d4ac..d42b347c 100644 --- a/src/auth/admin.test.ts +++ b/tests/auth/admin.test.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from "bun:test" import express from "express" import request from "supertest" -import { adminProtected } from "./admin" -import { generateJWT } from "./jwt" +import { adminProtected } from "@/auth/admin" +import { generateJWT } from "@/auth/jwt" const app = express() diff --git a/src/core/RaidHubRoute.test.ts b/tests/core/RaidHubRoute.test.ts similarity index 99% rename from src/core/RaidHubRoute.test.ts rename to tests/core/RaidHubRoute.test.ts index 743cab18..042e6da1 100644 --- a/src/core/RaidHubRoute.test.ts +++ b/tests/core/RaidHubRoute.test.ts @@ -9,7 +9,7 @@ import express from "express" import request from "supertest" import { z } from "zod" -import { RaidHubRoute } from "./RaidHubRoute" +import { RaidHubRoute } from "@/core/RaidHubRoute" const app = express() diff --git a/src/integrations/bungie/client.test.ts b/tests/integrations/bungie/client.test.ts similarity index 95% rename from src/integrations/bungie/client.test.ts rename to tests/integrations/bungie/client.test.ts index df8bf5e1..2aa0051f 100644 --- a/src/integrations/bungie/client.test.ts +++ b/tests/integrations/bungie/client.test.ts @@ -1,7 +1,7 @@ import { afterAll, beforeEach, describe, expect, spyOn, test } from "bun:test" import { getDestinyManifest, transferItem } from "bungie-net-core/endpoints/Destiny2" -import { bungiePlatformHttp } from "./client" -import { BungieApiError } from "./error" +import { bungiePlatformHttp } from "@/integrations/bungie/client" +import { BungieApiError } from "@/integrations/bungie/error" describe("bungie http client", () => { const bungieHttp = bungiePlatformHttp({ diff --git a/src/integrations/postgres/postgres.test.ts b/tests/integrations/postgres/postgres.test.ts similarity index 100% rename from src/integrations/postgres/postgres.test.ts rename to tests/integrations/postgres/postgres.test.ts diff --git a/src/lib/utils/internal-api-client.test.ts b/tests/lib/utils/internal-api-client.test.ts similarity index 97% rename from src/lib/utils/internal-api-client.test.ts rename to tests/lib/utils/internal-api-client.test.ts index 0a6650b5..465b31fe 100644 --- a/src/lib/utils/internal-api-client.test.ts +++ b/tests/lib/utils/internal-api-client.test.ts @@ -1,5 +1,5 @@ import { afterAll, beforeEach, describe, expect, spyOn, test } from "bun:test" -import { InternalApiError, internalApiFetch } from "./internal-api-client" +import { InternalApiError, internalApiFetch } from "@/lib/utils/internal-api-client" describe("internalApiFetch", () => { const spyFetch = spyOn(globalThis, "fetch") diff --git a/src/middleware/cache-control.test.ts b/tests/middleware/cache-control.test.ts similarity index 94% rename from src/middleware/cache-control.test.ts rename to tests/middleware/cache-control.test.ts index 28f7d11e..790a6816 100644 --- a/src/middleware/cache-control.test.ts +++ b/tests/middleware/cache-control.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from "bun:test" import express from "express" import request from "supertest" -import { cacheControl } from "./cache-control" +import { cacheControl } from "@/middleware/cache-control" const app = express() diff --git a/src/routes/admin/query.test.ts b/tests/routes/admin/query.test.ts similarity index 97% rename from src/routes/admin/query.test.ts rename to tests/routes/admin/query.test.ts index ef5ab815..c987c58c 100644 --- a/src/routes/admin/query.test.ts +++ b/tests/routes/admin/query.test.ts @@ -1,6 +1,6 @@ import { expectErr, expectOk } from "@/lib/test-utils" import { describe, test } from "bun:test" -import { adminQueryRoute } from "./query" +import { adminQueryRoute } from "@/routes/admin/query" describe("admin query 200", () => { const t = async (query: string, type: string, ignoreCost?: boolean) => { diff --git a/src/routes/admin/reporting/instance-standing.test.ts b/tests/routes/admin/reporting/instance-standing.test.ts similarity index 90% rename from src/routes/admin/reporting/instance-standing.test.ts rename to tests/routes/admin/reporting/instance-standing.test.ts index 3cac426b..7564e242 100644 --- a/src/routes/admin/reporting/instance-standing.test.ts +++ b/tests/routes/admin/reporting/instance-standing.test.ts @@ -1,7 +1,7 @@ import { expectErr, expectOk } from "@/lib/test-utils" import { ErrorCode } from "@/schema/errors/ErrorCode" import { describe, expect, test } from "bun:test" -import { reportingStandingInstanceRoute } from "./instance-standing" +import { reportingStandingInstanceRoute } from "@/routes/admin/reporting/instance-standing" describe("instance standing 200", () => { const t = async (instanceId: string) => { diff --git a/src/routes/authorize/admin.test.ts b/tests/routes/authorize/admin.test.ts similarity index 94% rename from src/routes/authorize/admin.test.ts rename to tests/routes/authorize/admin.test.ts index b1b8d8c8..42e9f106 100644 --- a/src/routes/authorize/admin.test.ts +++ b/tests/routes/authorize/admin.test.ts @@ -1,7 +1,7 @@ import { expectErr, expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" import jwt from "jsonwebtoken" -import { adminAuthorizationRoute } from "./admin" +import { adminAuthorizationRoute } from "@/routes/authorize/admin" describe("authorize 200", () => { test("admin", async () => { diff --git a/src/routes/authorize/user.test.ts b/tests/routes/authorize/user.test.ts similarity index 95% rename from src/routes/authorize/user.test.ts rename to tests/routes/authorize/user.test.ts index 251d3968..98fea001 100644 --- a/src/routes/authorize/user.test.ts +++ b/tests/routes/authorize/user.test.ts @@ -1,7 +1,7 @@ import { expectErr, expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" import jwt from "jsonwebtoken" -import { userAuthorizationRoute } from "./user" +import { userAuthorizationRoute } from "@/routes/authorize/user" describe("authorize 200", () => { test("user", async () => { diff --git a/src/routes/clanStats.test.ts b/tests/routes/clanStats.test.ts similarity index 98% rename from src/routes/clanStats.test.ts rename to tests/routes/clanStats.test.ts index defe8671..202acf66 100644 --- a/src/routes/clanStats.test.ts +++ b/tests/routes/clanStats.test.ts @@ -5,7 +5,7 @@ import { expectErr, expectOk } from "@/lib/test-utils" import { ErrorCode } from "@/schema/errors/ErrorCode" import { afterAll, beforeEach, describe, expect, spyOn, test } from "bun:test" import { PlatformErrorCodes } from "bungie-net-core/enums" -import { clanStatsRoute } from "./clanStats" +import { clanStatsRoute } from "@/routes/clanStats" describe("clan 200", () => { const spyClanQueueSend = spyOn(clanQueue, "send") diff --git a/src/routes/instance.test.ts b/tests/routes/instance.test.ts similarity index 97% rename from src/routes/instance.test.ts rename to tests/routes/instance.test.ts index 00e48f16..85f8758c 100644 --- a/src/routes/instance.test.ts +++ b/tests/routes/instance.test.ts @@ -3,7 +3,7 @@ import { afterAll, beforeEach, describe, expect, spyOn, test } from "bun:test" import { instanceCharacterQueue, playersQueue } from "@/integrations/rabbitmq/queues" import { expectErr, expectOk } from "@/lib/test-utils" -import { instanceRoute } from "./instance" +import { instanceRoute } from "@/routes/instance" describe("activity 200", () => { const spyCharQueueSend = spyOn(instanceCharacterQueue, "sendJson") diff --git a/src/routes/leaderboard/clan.test.ts b/tests/routes/leaderboard/clan.test.ts similarity index 93% rename from src/routes/leaderboard/clan.test.ts rename to tests/routes/leaderboard/clan.test.ts index d8fa6dac..19902c22 100644 --- a/src/routes/leaderboard/clan.test.ts +++ b/tests/routes/leaderboard/clan.test.ts @@ -1,6 +1,6 @@ import { expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" -import { clanLeaderboardRoute } from "./clan" +import { clanLeaderboardRoute } from "@/routes/leaderboard/clan" describe("clan leaderboard 200", () => { const t = async (query?: Record) => { diff --git a/src/routes/leaderboard/team/contest.test.ts b/tests/routes/leaderboard/contest.test.ts similarity index 95% rename from src/routes/leaderboard/team/contest.test.ts rename to tests/routes/leaderboard/contest.test.ts index 3c7bf432..1be75f0a 100644 --- a/src/routes/leaderboard/team/contest.test.ts +++ b/tests/routes/leaderboard/contest.test.ts @@ -1,6 +1,6 @@ import { expectErr, expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" -import { leaderboardTeamContestRoute } from "./contest" +import { leaderboardTeamContestRoute } from "@/routes/leaderboard/team/contest" describe("contest leaderboard 200", () => { const t = async ( diff --git a/src/routes/leaderboard/team/first.test.ts b/tests/routes/leaderboard/first.test.ts similarity index 95% rename from src/routes/leaderboard/team/first.test.ts rename to tests/routes/leaderboard/first.test.ts index afeea4f4..bebc59d5 100644 --- a/src/routes/leaderboard/team/first.test.ts +++ b/tests/routes/leaderboard/first.test.ts @@ -1,6 +1,6 @@ import { expectErr, expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" -import { leaderboardTeamFirstActivityVersionRoute } from "./first" +import { leaderboardTeamFirstActivityVersionRoute } from "@/routes/leaderboard/team/first" describe("first leaderboard 200", () => { const t = async ( diff --git a/src/routes/leaderboard/individual/global.test.ts b/tests/routes/leaderboard/global.test.ts similarity index 96% rename from src/routes/leaderboard/individual/global.test.ts rename to tests/routes/leaderboard/global.test.ts index dccabab6..e808e07c 100644 --- a/src/routes/leaderboard/individual/global.test.ts +++ b/tests/routes/leaderboard/global.test.ts @@ -1,6 +1,6 @@ import { expectErr, expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" -import { leaderboardIndividualGlobalRoute } from "./global" +import { leaderboardIndividualGlobalRoute } from "@/routes/leaderboard/individual/global" describe("global leaderboard 200", () => { const t = async ( diff --git a/src/routes/leaderboard/individual/pantheon.test.ts b/tests/routes/leaderboard/pantheon.test.ts similarity index 95% rename from src/routes/leaderboard/individual/pantheon.test.ts rename to tests/routes/leaderboard/pantheon.test.ts index 823eac3d..ff5bfb35 100644 --- a/src/routes/leaderboard/individual/pantheon.test.ts +++ b/tests/routes/leaderboard/pantheon.test.ts @@ -1,6 +1,6 @@ import { expectErr, expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" -import { leaderboardIndividualPantheonRoute } from "./pantheon" +import { leaderboardIndividualPantheonRoute } from "@/routes/leaderboard/individual/pantheon" describe("pantheon leaderboard 200", () => { const t = async ( diff --git a/src/routes/leaderboard/individual/raid.test.ts b/tests/routes/leaderboard/raid.test.ts similarity index 95% rename from src/routes/leaderboard/individual/raid.test.ts rename to tests/routes/leaderboard/raid.test.ts index 2c7dc551..9f612478 100644 --- a/src/routes/leaderboard/individual/raid.test.ts +++ b/tests/routes/leaderboard/raid.test.ts @@ -1,6 +1,6 @@ import { expectErr, expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" -import { leaderboardIndividualRaidRoute } from "./raid" +import { leaderboardIndividualRaidRoute } from "@/routes/leaderboard/individual/raid" describe("raid leaderboard 200", () => { const t = async ( diff --git a/src/routes/manifest.test.ts b/tests/routes/manifest.test.ts similarity index 78% rename from src/routes/manifest.test.ts rename to tests/routes/manifest.test.ts index b9a860e4..66dc2684 100644 --- a/src/routes/manifest.test.ts +++ b/tests/routes/manifest.test.ts @@ -1,6 +1,6 @@ import { expectOk } from "@/lib/test-utils" import { test } from "bun:test" -import { manifestRoute } from "./manifest" +import { manifestRoute } from "@/routes/manifest" test("manifest 200", async () => { const result = await manifestRoute.$mock() diff --git a/src/routes/metrics/dailyPlayerPopulation.test.ts b/tests/routes/metrics/dailyPlayerPopulation.test.ts similarity index 84% rename from src/routes/metrics/dailyPlayerPopulation.test.ts rename to tests/routes/metrics/dailyPlayerPopulation.test.ts index 2ca0a85e..e47167bb 100644 --- a/src/routes/metrics/dailyPlayerPopulation.test.ts +++ b/tests/routes/metrics/dailyPlayerPopulation.test.ts @@ -1,6 +1,6 @@ import { expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" -import { dailyPlayerPopulationRoute } from "./dailyPlayerPopulation" +import { dailyPlayerPopulationRoute } from "@/routes/metrics/dailyPlayerPopulation" describe("player population 200", () => { test("it works", async () => { diff --git a/src/routes/metrics/weaponsRollingWeekRoute.test.ts b/tests/routes/metrics/weaponsRollingWeekRoute.test.ts similarity index 92% rename from src/routes/metrics/weaponsRollingWeekRoute.test.ts rename to tests/routes/metrics/weaponsRollingWeekRoute.test.ts index 8bb24f69..bfab554c 100644 --- a/src/routes/metrics/weaponsRollingWeekRoute.test.ts +++ b/tests/routes/metrics/weaponsRollingWeekRoute.test.ts @@ -1,6 +1,6 @@ import { expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" -import { weaponsRollingWeekRoute } from "./weaponsRollingWeek" +import { weaponsRollingWeekRoute } from "@/routes/metrics/weaponsRollingWeek" describe("weekly weapon meta 200", () => { const t = async (query: unknown) => { diff --git a/src/routes/pgcr.test.ts b/tests/routes/pgcr.test.ts similarity index 94% rename from src/routes/pgcr.test.ts rename to tests/routes/pgcr.test.ts index c4a0ee21..c83782c5 100644 --- a/src/routes/pgcr.test.ts +++ b/tests/routes/pgcr.test.ts @@ -2,7 +2,7 @@ import { describe, test } from "bun:test" import { expectErr, expectOk } from "@/lib/test-utils" -import { pgcrRoute } from "./pgcr" +import { pgcrRoute } from "@/routes/pgcr" describe("pgcr 200", () => { const t = async (instanceId: string) => { diff --git a/src/routes/player/membershipId/basic.test.ts b/tests/routes/player/basic.test.ts similarity index 90% rename from src/routes/player/membershipId/basic.test.ts rename to tests/routes/player/basic.test.ts index 263ca3c4..4f67c73e 100644 --- a/src/routes/player/membershipId/basic.test.ts +++ b/tests/routes/player/basic.test.ts @@ -2,7 +2,7 @@ import { describe, test } from "bun:test" import { expectErr, expectOk } from "@/lib/test-utils" -import { playerBasicRoute } from "./basic" +import { playerBasicRoute } from "@/routes/player/membershipId/basic" describe("player basic 200", () => { const t = async (membershipId: string) => { diff --git a/src/routes/player/membershipId/history.test.ts b/tests/routes/player/history.test.ts similarity index 97% rename from src/routes/player/membershipId/history.test.ts rename to tests/routes/player/history.test.ts index e1ebf319..5cccd0fa 100644 --- a/src/routes/player/membershipId/history.test.ts +++ b/tests/routes/player/history.test.ts @@ -5,7 +5,7 @@ import { expectErr, expectOk } from "@/lib/test-utils" import express from "express" import request from "supertest" -import { playerHistoryRoute } from "./history" +import { playerHistoryRoute } from "@/routes/player/membershipId/history" describe("player activities 200", () => { const t = async (membershipId: string, cursor?: Date) => { diff --git a/src/routes/player/membershipId/instances.test.ts b/tests/routes/player/instances.test.ts similarity index 97% rename from src/routes/player/membershipId/instances.test.ts rename to tests/routes/player/instances.test.ts index a3a3f8fe..eaa1ac60 100644 --- a/src/routes/player/membershipId/instances.test.ts +++ b/tests/routes/player/instances.test.ts @@ -4,7 +4,7 @@ import { generateJWT } from "@/auth/jwt" import { expectErr, expectOk } from "@/lib/test-utils" import { ErrorCode } from "@/schema/errors/ErrorCode" -import { playerInstancesRoute } from "./instances" +import { playerInstancesRoute } from "@/routes/player/membershipId/instances" describe("instances 200", () => { const membershipId = "4611686018488107374" diff --git a/src/routes/player/membershipId/profile.test.ts b/tests/routes/player/profile.test.ts similarity index 95% rename from src/routes/player/membershipId/profile.test.ts rename to tests/routes/player/profile.test.ts index 52e09712..0b667feb 100644 --- a/src/routes/player/membershipId/profile.test.ts +++ b/tests/routes/player/profile.test.ts @@ -3,7 +3,7 @@ import { describe, test } from "bun:test" import { generateJWT } from "@/auth/jwt" import { expectErr, expectOk } from "@/lib/test-utils" -import { playerProfileRoute } from "./profile" +import { playerProfileRoute } from "@/routes/player/membershipId/profile" describe("player profile 200", () => { const t = async (membershipId: string) => { diff --git a/src/routes/player/search.test.ts b/tests/routes/player/search.test.ts similarity index 96% rename from src/routes/player/search.test.ts rename to tests/routes/player/search.test.ts index b44cf0d1..36bc9274 100644 --- a/src/routes/player/search.test.ts +++ b/tests/routes/player/search.test.ts @@ -1,6 +1,6 @@ import { expectOk } from "@/lib/test-utils" import { describe, expect, test } from "bun:test" -import { playerSearchRoute } from "./search" +import { playerSearchRoute } from "@/routes/player/search" describe("player search 200", () => { const t = async (query: unknown) => { diff --git a/src/routes/player/membershipId/teammates.test.ts b/tests/routes/player/teammates.test.ts similarity index 95% rename from src/routes/player/membershipId/teammates.test.ts rename to tests/routes/player/teammates.test.ts index 3ebdccba..48a2e24f 100644 --- a/src/routes/player/membershipId/teammates.test.ts +++ b/tests/routes/player/teammates.test.ts @@ -3,7 +3,7 @@ import { describe, test } from "bun:test" import { generateJWT } from "@/auth/jwt" import { expectErr, expectOk } from "@/lib/test-utils" -import { playerTeammatesRoute } from "./teammates" +import { playerTeammatesRoute } from "@/routes/player/membershipId/teammates" describe("teammates 200", () => { const t = async (membershipId: string) => { diff --git a/src/routes/status.test.ts b/tests/routes/status.test.ts similarity index 99% rename from src/routes/status.test.ts rename to tests/routes/status.test.ts index 8947c610..ff6b6801 100644 --- a/src/routes/status.test.ts +++ b/tests/routes/status.test.ts @@ -8,7 +8,7 @@ import * as BungieCoreEndpoints from "bungie-net-core/endpoints/Core" import { BungieNetResponse } from "bungie-net-core/interfaces" import { CoreSettingsConfiguration } from "bungie-net-core/models" -import { statusRoute, statusState } from "./status" +import { statusRoute, statusState } from "@/routes/status" describe("status 200", async () => { const spyGetAtlasStatus = spyOn(AtlasModule, "getAtlasStatus") diff --git a/src/services/atlas/atlas.test.ts b/tests/services/atlas/atlas.test.ts similarity index 98% rename from src/services/atlas/atlas.test.ts rename to tests/services/atlas/atlas.test.ts index a8410eb6..cc532866 100644 --- a/src/services/atlas/atlas.test.ts +++ b/tests/services/atlas/atlas.test.ts @@ -1,5 +1,5 @@ import { afterAll, beforeEach, describe, expect, spyOn, test } from "bun:test" -import { getAtlasStatus } from "." +import { getAtlasStatus } from "@/services/atlas" describe("getAtlasStatus with mock", () => { const spyFetch = spyOn(globalThis, "fetch") diff --git a/src/services/clans/clan.test.ts b/tests/services/clans/clan.test.ts similarity index 92% rename from src/services/clans/clan.test.ts rename to tests/services/clans/clan.test.ts index 4c8c5108..da8c58e7 100644 --- a/src/services/clans/clan.test.ts +++ b/tests/services/clans/clan.test.ts @@ -1,7 +1,7 @@ import { getClanMembers } from "@/integrations/bungie" import { zClanStats } from "@/schema/components/Clan" import { describe, expect, test } from "bun:test" -import { getClanStats } from "./clan-stats" +import { getClanStats } from "@/services/clans/clan-stats" describe("getClanStats", () => { test("returns the correct shape", async () => { diff --git a/src/services/clans/leaderboard.test.ts b/tests/services/clans/leaderboard.test.ts similarity index 91% rename from src/services/clans/leaderboard.test.ts rename to tests/services/clans/leaderboard.test.ts index cb0cd6ec..28152245 100644 --- a/src/services/clans/leaderboard.test.ts +++ b/tests/services/clans/leaderboard.test.ts @@ -1,7 +1,7 @@ import { zClanLeaderboardEntry } from "@/schema/components/Clan" import { describe, expect, test } from "bun:test" import { z } from "zod" -import { getClanLeaderboard } from "./leaderboard" +import { getClanLeaderboard } from "@/services/clans/leaderboard" describe("getClanLeaderboard", () => { test("returns the correct shape", async () => { diff --git a/src/services/floodgates/floodgates.test.ts b/tests/services/floodgates/floodgates.test.ts similarity index 98% rename from src/services/floodgates/floodgates.test.ts rename to tests/services/floodgates/floodgates.test.ts index ed34a765..39d39195 100644 --- a/src/services/floodgates/floodgates.test.ts +++ b/tests/services/floodgates/floodgates.test.ts @@ -1,6 +1,6 @@ import * as MockRabbitAPI from "@/integrations/rabbitmq/api" import { afterAll, beforeEach, describe, expect, spyOn, test } from "bun:test" -import { getFloodgatesRecentId, getFloodgatesStatus } from "." +import { getFloodgatesRecentId, getFloodgatesStatus } from "@/services/floodgates" describe("getFloodgatesRecentId with mock", () => { const spyFetch = spyOn(globalThis, "fetch") diff --git a/src/services/instance/instance.test.ts b/tests/services/instance/instance.test.ts similarity index 99% rename from src/services/instance/instance.test.ts rename to tests/services/instance/instance.test.ts index fd77a738..f99739b2 100644 --- a/src/services/instance/instance.test.ts +++ b/tests/services/instance/instance.test.ts @@ -8,7 +8,7 @@ import { getInstanceExtended, getInstanceMetadataByHash, getLeaderboardEntryForInstance -} from "./instance" +} from "@/services/instance/instance" describe("getInstance", () => { test("returns the correct shape", async () => { diff --git a/src/services/leaderboard/contest.test.ts b/tests/services/leaderboard/contest.test.ts similarity index 100% rename from src/services/leaderboard/contest.test.ts rename to tests/services/leaderboard/contest.test.ts diff --git a/src/services/leaderboard/first.test.ts b/tests/services/leaderboard/first.test.ts similarity index 100% rename from src/services/leaderboard/first.test.ts rename to tests/services/leaderboard/first.test.ts diff --git a/src/services/leaderboard/global.test.ts b/tests/services/leaderboard/global.test.ts similarity index 100% rename from src/services/leaderboard/global.test.ts rename to tests/services/leaderboard/global.test.ts diff --git a/src/services/leaderboard/pantheon.test.ts b/tests/services/leaderboard/pantheon.test.ts similarity index 100% rename from src/services/leaderboard/pantheon.test.ts rename to tests/services/leaderboard/pantheon.test.ts diff --git a/src/services/leaderboard/raid.test.ts b/tests/services/leaderboard/raid.test.ts similarity index 100% rename from src/services/leaderboard/raid.test.ts rename to tests/services/leaderboard/raid.test.ts diff --git a/src/services/manifest/definitions.test.ts b/tests/services/manifest/definitions.test.ts similarity index 98% rename from src/services/manifest/definitions.test.ts rename to tests/services/manifest/definitions.test.ts index cc2601b1..5d5c871c 100644 --- a/src/services/manifest/definitions.test.ts +++ b/tests/services/manifest/definitions.test.ts @@ -12,7 +12,7 @@ import { listFeatDefinitions, listHashes, listVersionDefinitions -} from "./definitions" +} from "@/services/manifest/definitions" describe("getRaidId", () => { test("returns the correct shape", async () => { diff --git a/src/services/metrics/daily-player-population.test.ts b/tests/services/metrics/daily-player-population.test.ts similarity index 100% rename from src/services/metrics/daily-player-population.test.ts rename to tests/services/metrics/daily-player-population.test.ts diff --git a/src/services/metrics/rolling-weapon-meta.test.ts b/tests/services/metrics/rolling-weapon-meta.test.ts similarity index 90% rename from src/services/metrics/rolling-weapon-meta.test.ts rename to tests/services/metrics/rolling-weapon-meta.test.ts index 3dd78a60..800ca66d 100644 --- a/src/services/metrics/rolling-weapon-meta.test.ts +++ b/tests/services/metrics/rolling-weapon-meta.test.ts @@ -1,7 +1,7 @@ import { zWeaponMetric } from "@/schema/components/Metrics" import { describe, expect, test } from "bun:test" import { z } from "zod" -import { getRollingWeaponMeta } from "./rolling-weapon-meta" +import { getRollingWeaponMeta } from "@/services/metrics/rolling-weapon-meta" describe("getRollingWeaponMeta", () => { test("returns the correct shape", async () => { diff --git a/src/services/pgcr.test.ts b/tests/services/pgcr.test.ts similarity index 91% rename from src/services/pgcr.test.ts rename to tests/services/pgcr.test.ts index 022df1c1..1be495c2 100644 --- a/src/services/pgcr.test.ts +++ b/tests/services/pgcr.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test" import { z } from "zod" -import { getRawCompressedPGCR } from "./pgcr" +import { getRawCompressedPGCR } from "@/services/pgcr" describe("getRawCompressedPGCR", () => { test("returns the correct shape", async () => { diff --git a/src/services/player-instances/history.test.ts b/tests/services/player-instances/history.test.ts similarity index 97% rename from src/services/player-instances/history.test.ts rename to tests/services/player-instances/history.test.ts index 9c00c944..c61c7c26 100644 --- a/src/services/player-instances/history.test.ts +++ b/tests/services/player-instances/history.test.ts @@ -2,7 +2,7 @@ import { zInstanceForPlayer } from "@/schema/components/InstanceForPlayer" import { getInstancePlayerInfo } from "@/services/instance/instance" import { describe, expect, test } from "bun:test" import { z } from "zod" -import { getActivities } from "./history" +import { getActivities } from "@/services/player-instances/history" describe("getActivities", () => { test("returns the correct shape", async () => { diff --git a/src/services/player-instances/instances.test.ts b/tests/services/player-instances/instances.test.ts similarity index 99% rename from src/services/player-instances/instances.test.ts rename to tests/services/player-instances/instances.test.ts index ef76612d..cbc4df0e 100644 --- a/src/services/player-instances/instances.test.ts +++ b/tests/services/player-instances/instances.test.ts @@ -2,7 +2,7 @@ import { zInstanceWithPlayers } from "@/schema/components/InstanceWithPlayers" import { getInstancePlayerInfo } from "@/services/instance/instance" import { describe, expect, test } from "bun:test" import { z } from "zod" -import { getInstances } from "./instances" +import { getInstances } from "@/services/player-instances/instances" describe("getInstances", () => { test("returns the correct shape", async () => { diff --git a/src/services/player-instances/teammates.test.ts b/tests/services/player-instances/teammates.test.ts similarity index 90% rename from src/services/player-instances/teammates.test.ts rename to tests/services/player-instances/teammates.test.ts index 271273ee..b7943f70 100644 --- a/src/services/player-instances/teammates.test.ts +++ b/tests/services/player-instances/teammates.test.ts @@ -1,7 +1,7 @@ import { zTeammate } from "@/schema/components/Teammate" import { describe, expect, test } from "bun:test" import { z } from "zod" -import { getTeammates } from "./teammates" +import { getTeammates } from "@/services/player-instances/teammates" describe("getTeammates", () => { test("returns the correct shape", async () => { diff --git a/src/services/player.test.ts b/tests/services/player.test.ts similarity index 98% rename from src/services/player.test.ts rename to tests/services/player.test.ts index ee620b2e..db468b9e 100644 --- a/src/services/player.test.ts +++ b/tests/services/player.test.ts @@ -14,7 +14,7 @@ import { getPlayerActivityStats, getPlayerGlobalStats, getWorldFirstEntries -} from "./player" +} from "@/services/player" describe("getPlayer", () => { test("returns the correct shape", async () => { diff --git a/src/services/reporting/standing.test.ts b/tests/services/reporting/standing.test.ts similarity index 97% rename from src/services/reporting/standing.test.ts rename to tests/services/reporting/standing.test.ts index b0b58d2b..7281daf6 100644 --- a/src/services/reporting/standing.test.ts +++ b/tests/services/reporting/standing.test.ts @@ -5,7 +5,7 @@ import { } from "@/schema/components/InstanceStanding" import { describe, expect, test } from "bun:test" import { z } from "zod" -import { getInstanceBlacklist, getInstanceFlags, getInstancePlayersStanding } from "./standing" +import { getInstanceBlacklist, getInstanceFlags, getInstancePlayersStanding } from "@/services/reporting/standing" describe("getInstanceFlags", () => { test("returns the correct shape", async () => { diff --git a/src/services/search/player-search.test.ts b/tests/services/search/player-search.test.ts similarity index 95% rename from src/services/search/player-search.test.ts rename to tests/services/search/player-search.test.ts index 8c6aaafd..9b259d7a 100644 --- a/src/services/search/player-search.test.ts +++ b/tests/services/search/player-search.test.ts @@ -1,7 +1,7 @@ import { zPlayerInfo } from "@/schema/components/PlayerInfo" import { describe, expect, test } from "bun:test" import { z } from "zod" -import { searchForPlayer } from "./player-search" +import { searchForPlayer } from "@/services/search/player-search" describe("searchForPlayer", () => { test("returns the correct shape", async () => { diff --git a/tsconfig.json b/tsconfig.json index 8018138d..bfa26fad 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -32,7 +32,7 @@ }, "include": [ "src/**/*.ts", - "src/**/*.test.ts", + "tests/**/*.ts", "open-api/generate.ts", "api-keys.json" ]