mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
[web] Consolidate ide settings in `features/ide-settings` GitOrigin-RevId: cbf0ff069399f418d8cb0d8165628df190046ea9
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { screen, within, render } from '@testing-library/react'
|
|
import { expect } from 'chai'
|
|
import { SettingsModalProvider } from '@/features/ide-settings/context/settings-modal-context'
|
|
import {
|
|
EditorProviders,
|
|
projectDefaults,
|
|
} from '../../../helpers/editor-providers'
|
|
import userEvent from '@testing-library/user-event'
|
|
import DraftSetting from '@/features/ide-settings/components/compiler-settings/draft-setting'
|
|
|
|
const OPTIONS = [
|
|
{
|
|
label: 'Normal',
|
|
value: false,
|
|
},
|
|
{
|
|
label: 'Fast [draft]',
|
|
value: true,
|
|
},
|
|
]
|
|
|
|
describe('<DraftSetting />', function () {
|
|
it('each option is shown and can be selected', async function () {
|
|
render(
|
|
<EditorProviders>
|
|
<SettingsModalProvider>
|
|
<DraftSetting />
|
|
</SettingsModalProvider>
|
|
</EditorProviders>
|
|
)
|
|
|
|
const select = screen.getByLabelText('Compile mode')
|
|
|
|
for (const option of OPTIONS) {
|
|
const optionElement = within(select).getByText(option.label)
|
|
expect(optionElement.getAttribute('value')).to.equal(
|
|
option.value.toString()
|
|
)
|
|
await userEvent.selectOptions(select, [optionElement])
|
|
expect(!!localStorage.getItem(`draft:${projectDefaults._id}`)).to.equal(
|
|
option.value
|
|
)
|
|
}
|
|
})
|
|
})
|