-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
- Loading branch information
1 parent
66e3398
commit f38fb48
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/rmf-dashboard-framework/src/components/tasks/types/custom-compose.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import { describe, expect, it, vi } from 'vitest'; | ||
|
||
import { CustomComposeTaskForm } from './custom-compose'; | ||
|
||
describe('Custom compose task form', () => { | ||
it('Renders custom compose task form', async () => { | ||
const onChange = vi.fn(); | ||
const onValidate = vi.fn(); | ||
|
||
render(<CustomComposeTaskForm taskDesc={''} onChange={onChange} onValidate={onValidate} />); | ||
}); | ||
|
||
it('CustomComposeTaskForm validates input', () => { | ||
const onChange = vi.fn(); | ||
const onValidate = vi.fn(); | ||
|
||
render(<CustomComposeTaskForm taskDesc="" onChange={onChange} onValidate={onValidate} />); | ||
|
||
const textArea = screen.getByRole('textbox', { name: /multiline/i }); | ||
|
||
// Invalid input (invalid JSON) | ||
fireEvent.change(textArea, { target: { value: 'invalid json' } }); | ||
expect(onValidate).toHaveBeenCalledWith(false); | ||
|
||
// Valid input | ||
const validTaskDesc = '{"valid": "json"}'; | ||
fireEvent.change(textArea, { target: { value: validTaskDesc } }); | ||
expect(onValidate).toHaveBeenCalledWith(true); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/rmf-dashboard-framework/src/components/tasks/types/cutsom-compose.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { CustomComposeTaskForm } from './custom-compose'; | ||
|
||
export default { | ||
title: 'Tasks/CustomComposeTaskForm', | ||
component: CustomComposeTaskForm, | ||
} satisfies Meta; | ||
|
||
type Story = StoryObj<typeof CustomComposeTaskForm>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
taskDesc: '', | ||
onChange: () => {}, | ||
onValidate: () => {}, | ||
}, | ||
}; |