1
Fork 0

fix mock init error

This commit is contained in:
Konstantin Koval 2024-06-10 21:51:14 +03:00
parent cf38b3337d
commit eddb3badc9
1 changed files with 19 additions and 19 deletions

View File

@ -4,7 +4,25 @@ import { NotificationType } from '../../__generated__/globalTypes'
import { MessageState } from './Messages' import { MessageState } from './Messages'
import MessagePlain from './Message' import MessagePlain from './Message'
import MessageProgress from './MessageProgress' import MessageProgress from './MessageProgress'
import SubscriptionsHook from './SubscriptionsHook'
// Define the mock for SubscriptionsHook before using it
const MockSubscriptionsHook = ({ messages, setMessages }: any) => {
return (
<div>
<button
onClick={() => setMessages([...messages, ...messages])}
data-testid="trigger-messages"
>
Trigger Messages
</button>
</div>
)
}
vi.mock('./SubscriptionsHook', () => ({
__esModule: true,
default: MockSubscriptionsHook,
}))
const messages = [ const messages = [
{ {
@ -48,24 +66,6 @@ const messages = [
}, },
] ]
const MockSubscriptionsHook = ({ messages, setMessages }: any) => {
return (
<div>
<button
onClick={() => setMessages([...messages, ...messages])}
data-testid="trigger-messages"
>
Trigger Messages
</button>
</div>
)
}
vi.mock('./SubscriptionsHook', () => ({
__esModule: true,
default: MockSubscriptionsHook,
}))
describe('Messages Component', () => { describe('Messages Component', () => {
test('renders different types of messages with correct background colors', () => { test('renders different types of messages with correct background colors', () => {
render( render(