|
|
@@ -4,10 +4,10 @@ import fetchMock from 'fetch-mock'
|
|
|
import { SettingsModalProvider } from '@/features/ide-redesign/contexts/settings-modal-context'
|
|
|
import { EditorProviders } from '../../../helpers/editor-providers'
|
|
|
import EditorThemeSetting from '@/features/ide-redesign/components/settings/appearance-settings/editor-theme-setting'
|
|
|
+import userEvent from '@testing-library/user-event'
|
|
|
|
|
|
describe('<EditorThemeSetting />', function () {
|
|
|
const editorThemes = ['editortheme-1', 'editortheme-2', 'editortheme-3']
|
|
|
-
|
|
|
const legacyEditorThemes = ['legacytheme-1', 'legacytheme-2', 'legacytheme-3']
|
|
|
|
|
|
beforeEach(function () {
|
|
|
@@ -19,7 +19,7 @@ describe('<EditorThemeSetting />', function () {
|
|
|
fetchMock.removeRoutes().clearHistory()
|
|
|
})
|
|
|
|
|
|
- it('shows correct menu', async function () {
|
|
|
+ it('each option is shown and can be selected', async function () {
|
|
|
render(
|
|
|
<EditorProviders>
|
|
|
<SettingsModalProvider>
|
|
|
@@ -28,11 +28,25 @@ describe('<EditorThemeSetting />', function () {
|
|
|
</EditorProviders>
|
|
|
)
|
|
|
|
|
|
+ const saveSettingsMock = fetchMock.post(
|
|
|
+ `express:/user/settings`,
|
|
|
+ {
|
|
|
+ status: 200,
|
|
|
+ },
|
|
|
+ { delay: 0 }
|
|
|
+ )
|
|
|
+
|
|
|
const select = screen.getByLabelText('Editor theme')
|
|
|
|
|
|
for (const theme of editorThemes) {
|
|
|
const option = within(select).getByText(theme.replace(/_/g, ' '))
|
|
|
expect(option.getAttribute('value')).to.equal(theme)
|
|
|
+ await userEvent.selectOptions(select, [option])
|
|
|
+ expect(
|
|
|
+ saveSettingsMock.callHistory.called(`/user/settings`, {
|
|
|
+ body: { editorTheme: theme },
|
|
|
+ })
|
|
|
+ ).to.be.true
|
|
|
}
|
|
|
|
|
|
for (const theme of legacyEditorThemes) {
|
|
|
@@ -40,6 +54,12 @@ describe('<EditorThemeSetting />', function () {
|
|
|
theme.replace(/_/g, ' ') + ' (Legacy)'
|
|
|
)
|
|
|
expect(option.getAttribute('value')).to.equal(theme)
|
|
|
+ await userEvent.selectOptions(select, [option])
|
|
|
+ expect(
|
|
|
+ saveSettingsMock.callHistory.called(`/user/settings`, {
|
|
|
+ body: { editorTheme: theme },
|
|
|
+ })
|
|
|
+ ).to.be.true
|
|
|
}
|
|
|
})
|
|
|
})
|