Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
/**
* @jest-environment jsdom
*/
import React from 'react';
import { renderHook } from '@testing-library/react';
import { MessageContext, MessagePartIndex, useMessageContext } from '../message';
const surrounding: MessageContext = {
messageId: 'message-1',
conversationId: 'convo-1',
isExpanded: true,
isSubmitting: false,
isLatestMessage: true,
partIndex: 0,
};
describe('MessagePartIndex', () => {
it('provides the surrounding message at the part position', () => {
const { result } = renderHook(() => useMessageContext(), {
wrapper: ({ children }: { children: React.ReactNode }) => (
<MessageContext.Provider value={surrounding}>
<MessagePartIndex index={3}>{children}</MessagePartIndex>
</MessageContext.Provider>
),
});
expect(result.current).toEqual({ ...surrounding, partIndex: 3 });
});
it('sets only the position outside a message', () => {
const { result } = renderHook(() => useMessageContext(), {
wrapper: ({ children }: { children: React.ReactNode }) => (
<MessagePartIndex index={1}>{children}</MessagePartIndex>
),
});
expect(result.current).toEqual({ partIndex: 1 });
});
});