mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-08 08:39:03 +02:00
f27c99ea4b
* merging ide-redesign/components/file-tree into features/file-tree * moving ide-redesign/contexts/settings-modal-context to features/settings/contexts * use-collapsible-file-tree.tsx → features/file-tree/hooks * use-focus-on-setting.tsx → features/settings/hooks * use-project-notification-preferences.ts → features/settings/hooks * use-rail-overflow.tsx→ features/ide-react/hooks * deleting use-switch-enable-new-editor-state.ts * use-toolbar-menu-editor-commands.tsx → features/source-editor/hooks * npm run extract-translations * modifying the test to target correct buttons and removing a test for old component * adding a test back and modifying it * changing the test GitOrigin-RevId: baa1e9a992c88b84313eea82161354d4958cf1ef
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/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/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)
|
|
})
|
|
})
|