mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #34980 from overleaf/mj-ide-settings-feature
[web] Consolidate ide settings in `features/ide-settings` GitOrigin-RevId: cbf0ff069399f418d8cb0d8165628df190046ea9
This commit is contained in:
committed by
Copybot
parent
8e2edc4d8d
commit
3a3adf5e5a
@@ -0,0 +1,51 @@
|
||||
import { screen, render } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import fetchMock from 'fetch-mock'
|
||||
import { EditorProviders } from '../../../helpers/editor-providers'
|
||||
import { SettingsModalProvider } from '@/features/ide-settings/context/settings-modal-context'
|
||||
import CodeCheckSetting from '@/features/ide-settings/components/editor-settings/code-check-setting'
|
||||
|
||||
describe('<CodeCheckSetting />', function () {
|
||||
afterEach(function () {
|
||||
fetchMock.removeRoutes().clearHistory()
|
||||
})
|
||||
|
||||
it('can toggle', async function () {
|
||||
render(
|
||||
<EditorProviders>
|
||||
<SettingsModalProvider>
|
||||
<CodeCheckSetting />
|
||||
</SettingsModalProvider>
|
||||
</EditorProviders>
|
||||
)
|
||||
|
||||
const saveSettingsMock = fetchMock.post(
|
||||
`express:/user/settings`,
|
||||
{
|
||||
status: 200,
|
||||
},
|
||||
{ delay: 0 }
|
||||
)
|
||||
|
||||
const toggle = screen.getByLabelText('Code check')
|
||||
const startingCheckedValue = (toggle as HTMLInputElement).checked
|
||||
|
||||
// Toggle the checkbox
|
||||
toggle.click()
|
||||
expect((toggle as HTMLInputElement).checked).to.equal(!startingCheckedValue)
|
||||
expect(
|
||||
saveSettingsMock.callHistory.called(`/user/settings`, {
|
||||
body: { syntaxValidation: !startingCheckedValue },
|
||||
})
|
||||
).to.be.true
|
||||
|
||||
// Toggle back to original value
|
||||
toggle.click()
|
||||
expect((toggle as HTMLInputElement).checked).to.equal(startingCheckedValue)
|
||||
expect(
|
||||
saveSettingsMock.callHistory.called(`/user/settings`, {
|
||||
body: { syntaxValidation: startingCheckedValue },
|
||||
})
|
||||
).to.be.true
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user