* WIP: Custom updater modal Fixes #1663 * First working example with data * Clean up, moved code to index.tsx * Clean up * Nicer dialog * Add relaunch dialog (macOS) * max-height in case of a long text * Clean up * Add component tests and fix name consistency * Update styling, re-add md parser * Clean up * Quick typo * Clean up * Rebase on tauri v2 * Clean up * Add updater permissions * Remove dialog from config * Fix restart after install
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { fireEvent, render, screen } from '@testing-library/react'
|
|
import { vi } from 'vitest'
|
|
import { UpdaterModal } from './UpdaterModal'
|
|
|
|
describe('UpdaterModal tests', () => {
|
|
test('Renders the modal', () => {
|
|
const callback = vi.fn()
|
|
const data = {
|
|
version: '1.2.3',
|
|
date: '2021-22-23T21:22:23Z',
|
|
body: 'This is the body.',
|
|
}
|
|
|
|
render(
|
|
<UpdaterModal
|
|
isOpen={true}
|
|
onReject={() => {}}
|
|
onResolve={callback}
|
|
instanceId=""
|
|
open={false}
|
|
close={(res) => {}}
|
|
version={data.version}
|
|
date={data.date}
|
|
body={data.body}
|
|
/>
|
|
)
|
|
|
|
expect(screen.getByTestId('update-version')).toHaveTextContent(data.version)
|
|
|
|
const updateButton = screen.getByTestId('update-button-update')
|
|
expect(updateButton).toBeEnabled()
|
|
fireEvent.click(updateButton)
|
|
expect(callback.mock.calls).toHaveLength(1)
|
|
expect(callback.mock.lastCall[0]).toEqual({ wantUpdate: true })
|
|
|
|
const cancelButton = screen.getByTestId('update-button-cancel')
|
|
expect(cancelButton).toBeEnabled()
|
|
fireEvent.click(cancelButton)
|
|
expect(callback.mock.calls).toHaveLength(2)
|
|
expect(callback.mock.lastCall[0]).toEqual({ wantUpdate: false })
|
|
})
|
|
})
|