apphouse
Version:
Component library for React that uses observable state management and theme-able components.
32 lines (27 loc) • 835 B
text/typescript
import { Chat } from './Chat';
import { List } from './List';
import { makeAutoObservable } from 'mobx';
jest.mock('mobx', () => ({
makeAutoObservable: jest.fn()
}));
describe('Chat', () => {
beforeEach(() => {
jest.clearAllMocks();
});
it('should initialize with the provided users and history', () => {
const users = [
{ id: '1', name: 'User 1', role: 'user' },
{ id: '2', name: 'User 2', role: 'system' }
];
const history = [
{ id: '1', content: 'hello', userId: '1' },
{ id: '1', content: 'hello there', userId: '2' }
];
const chat = new Chat(users, history);
expect(chat.users).toEqual(users);
expect(JSON.stringify(chat.history)).toStrictEqual(
JSON.stringify(new List(history))
);
expect(makeAutoObservable).toHaveBeenCalledWith(chat);
});
});