mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 02:51:57 +02:00
* 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
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
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/settings/context/settings-modal-context'
|
|
import CodeCheckSetting from '@/features/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
|
|
})
|
|
})
|