mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
[web] Consolidate ide settings in `features/ide-settings` GitOrigin-RevId: cbf0ff069399f418d8cb0d8165628df190046ea9
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { screen, render } from '@testing-library/react'
|
|
import { expect } from 'chai'
|
|
import fetchMock from 'fetch-mock'
|
|
import { SettingsModalProvider } from '@/features/ide-settings/context/settings-modal-context'
|
|
import {
|
|
EditorProviders,
|
|
projectDefaults,
|
|
} from '../../../helpers/editor-providers'
|
|
import localStorage from '@/infrastructure/local-storage'
|
|
import userEvent from '@testing-library/user-event'
|
|
import StopOnFirstErrorSetting from '@/features/ide-settings/components/compiler-settings/stop-on-first-error-setting'
|
|
|
|
describe('<StopOnFirstErrorSetting />', function () {
|
|
afterEach(function () {
|
|
fetchMock.removeRoutes().clearHistory()
|
|
})
|
|
|
|
it('can toggle', async function () {
|
|
render(
|
|
<EditorProviders>
|
|
<SettingsModalProvider>
|
|
<StopOnFirstErrorSetting />
|
|
</SettingsModalProvider>
|
|
</EditorProviders>
|
|
)
|
|
|
|
const toggle = screen.getByLabelText('Stop on first error')
|
|
const startingCheckedValue = (toggle as HTMLInputElement).checked
|
|
|
|
// Toggle the checkbox
|
|
await userEvent.click(toggle)
|
|
expect((toggle as HTMLInputElement).checked).to.equal(!startingCheckedValue)
|
|
expect(
|
|
localStorage.getItem(`stop_on_first_error:${projectDefaults._id}`)
|
|
).to.equal(!startingCheckedValue)
|
|
|
|
// Toggle back to original value
|
|
await userEvent.click(toggle)
|
|
expect((toggle as HTMLInputElement).checked).to.equal(startingCheckedValue)
|
|
expect(
|
|
!!localStorage.getItem(`stop_on_first_error:${projectDefaults._id}`)
|
|
).to.equal(startingCheckedValue)
|
|
})
|
|
})
|