24 lines
735 B
JavaScript
24 lines
735 B
JavaScript
|
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||
|
|
import { JWT_SECRET, JWT_TOKEN_TTL } from '../../lib/auth-secret.js';
|
||
|
|
|
||
|
|
describe('lib/auth-secret', () => {
|
||
|
|
afterEach(() => {
|
||
|
|
vi.unstubAllEnvs();
|
||
|
|
vi.resetModules();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('exports JWT_SECRET equal to the value set in test/setup.js', () => {
|
||
|
|
expect(JWT_SECRET).toBe('test-secret-for-vitest-only-do-not-use-in-prod');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('exports JWT_TOKEN_TTL as the canonical 24h value', () => {
|
||
|
|
expect(JWT_TOKEN_TTL).toBe('24h');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('throws at module load when JWT_SECRET is unset', async () => {
|
||
|
|
vi.resetModules();
|
||
|
|
vi.stubEnv('JWT_SECRET', '');
|
||
|
|
await expect(import('../../lib/auth-secret.js')).rejects.toThrow(/JWT_SECRET/);
|
||
|
|
});
|
||
|
|
});
|