mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-05-02 17:55:07 +00:00
code: config,store,rate (2 files)
This commit is contained in:
@@ -5,7 +5,7 @@ import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
|
||||
export default tseslint.config(
|
||||
{ ignores: ['dist', 'node_modules', 'packages/*/dist', 'packages/*/node_modules', 'next-env.d.ts'] },
|
||||
{ ignores: ['dist', 'node_modules', 'packages/*/dist', 'packages/*/node_modules', 'next-env.d.ts', 'prisma.config.ts'] },
|
||||
{
|
||||
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
||||
|
||||
const mockGetSystemConfigValue = vi.fn()
|
||||
const ENV_RATE_LIMIT_WINDOW_MS = 'MB_RATE_LIMIT_WINDOW_MS'
|
||||
const ENV_MAX_REQUESTS = 'MB_RATE_LIMIT_MAX_REQUESTS'
|
||||
|
||||
vi.mock('@/lib/db/system-config/get-system-config-value', () => ({
|
||||
getSystemConfigValue: (key: string) => mockGetSystemConfigValue(key),
|
||||
@@ -14,14 +16,21 @@ import {
|
||||
resetRateLimitConfig,
|
||||
} from './rate-limit-store'
|
||||
|
||||
const resetRateLimitEnv = () => {
|
||||
delete process.env[ENV_RATE_LIMIT_WINDOW_MS]
|
||||
delete process.env[ENV_MAX_REQUESTS]
|
||||
}
|
||||
|
||||
describe('rate limit config loading', () => {
|
||||
beforeEach(() => {
|
||||
mockGetSystemConfigValue.mockReset()
|
||||
resetRateLimitEnv()
|
||||
resetRateLimitConfig()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
resetRateLimitConfig()
|
||||
resetRateLimitEnv()
|
||||
})
|
||||
|
||||
it('keeps env defaults when config is missing', async () => {
|
||||
|
||||
Reference in New Issue
Block a user