settings-keybindings.test.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. import { screen, within, render } from '@testing-library/react'
  2. import { expect } from 'chai'
  3. import fetchMock from 'fetch-mock'
  4. import SettingsKeybindings from '../../../../../../frontend/js/features/editor-left-menu/components/settings/settings-keybindings'
  5. import { EditorProviders } from '../../../../helpers/editor-providers'
  6. import { EditorLeftMenuProvider } from '@/features/editor-left-menu/components/editor-left-menu-context'
  7. describe('<SettingsKeybindings />', function () {
  8. afterEach(function () {
  9. fetchMock.removeRoutes().clearHistory()
  10. })
  11. it('shows correct menu', async function () {
  12. render(
  13. <EditorProviders>
  14. <EditorLeftMenuProvider>
  15. <SettingsKeybindings />
  16. </EditorLeftMenuProvider>
  17. </EditorProviders>
  18. )
  19. const select = screen.getByLabelText('Keybindings')
  20. const optionNone = within(select).getByText('None')
  21. expect(optionNone.getAttribute('value')).to.equal('default')
  22. const optionVim = within(select).getByText('Vim')
  23. expect(optionVim.getAttribute('value')).to.equal('vim')
  24. const optionEmacs = within(select).getByText('Emacs')
  25. expect(optionEmacs.getAttribute('value')).to.equal('emacs')
  26. })
  27. })