Skip to content

Commit

Permalink
some initial palceholder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ykumards committed Aug 27, 2024
1 parent 269c8dd commit e60d294
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 134 deletions.
62 changes: 0 additions & 62 deletions src/__tests__/components/Editor.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,6 @@ describe('Editor Component', () => {
);
};

test('toggles the emoji display when the switch is clicked', () => {
setup();

// Initially, emoji should be displayed
expect(screen.getByText('😀')).toBeInTheDocument();

// Find the toggle switch and click it
const toggleSwitch = screen.getByRole('checkbox');
fireEvent.click(toggleSwitch);

// Emoji should be hidden
expect(screen.queryByText('😀')).not.toBeInTheDocument();

// Click it again to show the emoji
fireEvent.click(toggleSwitch);
expect(screen.getByText('😀')).toBeInTheDocument();
});

test('displays loading message when loading is true', () => {
setup({ loading: true });

expect(screen.getByText('Loading Model')).toBeInTheDocument();
});

test('updates text state when user types in the textarea', () => {
const setText = vi.fn();
setup({ setText });
Expand All @@ -59,44 +35,6 @@ describe('Editor Component', () => {
expect(setText).toHaveBeenCalledWith('Hello, world!');
});

test('updates emoji and result text when worker returns data', async () => {
const setEmoji = vi.fn();
const setResultText = vi.fn();
const worker = {
current: {
postMessage: vi.fn(),
onmessage: vi.fn(), // Simulate onmessage as a function
},
};

setup({ setEmoji, setResultText, worker });

// Simulate worker response
const event = new MessageEvent('message', {
data: {
status: 'complete',
output: [{ label: 'joy' }],
},
});

// Trigger the onmessage event manually
worker.current.onmessage(event);

await waitFor(() => {
expect(setResultText).toHaveBeenCalledWith('joy');
expect(setEmoji).toHaveBeenCalledWith('😀');
});
});

test('calls saveToLocalStorage when Ctrl+Enter is pressed', () => {
const saveToLocalStorage = vi.fn();
setup({ saveToLocalStorage });

fireEvent.keyDown(window, { key: 'Enter', ctrlKey: true });

expect(saveToLocalStorage).toHaveBeenCalled();
});

test('textarea adjusts height automatically as text is typed', () => {
const { container } = setup();

Expand Down
72 changes: 0 additions & 72 deletions src/__tests__/context/EditorContext.test.jsx

This file was deleted.

0 comments on commit e60d294

Please sign in to comment.