@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
28 lines (21 loc) • 776 B
text/typescript
// @vitest-environment node
import { describe, expect, it } from 'vitest';
import { NON_HTTP_PREFIX } from '@/const/auth';
import { createJWT } from './jwt';
describe('createJWT', () => {
it('should create a JWT token', async () => {
const payload = { test: 'test' };
const token = await createJWT(payload);
expect(token).toBeTruthy();
});
it('should return a token with NON_HTTP_PREFIX when crypto.subtle does not exist', async () => {
const originalCryptoSubtle = crypto.subtle;
// @ts-ignore
crypto['subtle'] = undefined;
const payload = { test: 'test' };
const token = await createJWT(payload);
expect(token.startsWith(NON_HTTP_PREFIX)).toBeTruthy();
// @ts-ignore
crypto['subtle'] = originalCryptoSubtle;
});
});