overleaf/services/web/test/frontend/features/hotkeys-modal/components/hotkeys-modal.test.js
Alf Eaton 771a39f267 Merge pull request #3441 from overleaf/3803-hotkeys-modal
Migrate hotkeys modal to React

GitOrigin-RevId: 78399d3d62771cd296bdc2f4f8b1083263d31551
2020-12-11 03:04:42 +00:00

61 lines
1.8 KiB
JavaScript

import React from 'react'
import { render, screen } from '@testing-library/react'
import HotkeysModalContent from '../../../../../frontend/js/features/hotkeys-modal/components/hotkeys-modal-content'
import { expect } from 'chai'
const handleHide = () => {
// closed
}
describe('<HotkeysModalContent />', function() {
it('renders the translated modal title', function() {
const { container } = render(
<HotkeysModalContent handleHide={handleHide} />
)
expect(container.querySelector('.modal-title').textContent).to.equal(
'Hotkeys'
)
})
it('renders translated heading with embedded code', function() {
const { container } = render(
<HotkeysModalContent handleHide={handleHide} />
)
const results = container.querySelectorAll('h3 code')
expect(results).to.have.length(1)
})
it('renders the hotkey descriptions', function() {
const { container } = render(
<HotkeysModalContent handleHide={handleHide} />
)
const hotkeys = container.querySelectorAll('[data-test-selector="hotkey"]')
expect(hotkeys).to.have.length(19)
})
it('renders extra hotkey descriptions when Track Changes is enabled', function() {
const { container } = render(
<HotkeysModalContent handleHide={handleHide} trackChangesVisible />
)
const hotkeys = container.querySelectorAll('[data-test-selector="hotkey"]')
expect(hotkeys).to.have.length(22)
})
it('uses Ctrl for non-macOS', function() {
render(<HotkeysModalContent handleHide={handleHide} />)
screen.getAllByText(/Ctrl/)
expect(screen.queryByText(/Cmd/)).to.not.exist
})
it('uses Cmd for macOS', function() {
render(<HotkeysModalContent handleHide={handleHide} isMac />)
screen.getAllByText(/Cmd/)
expect(screen.queryByText(/Ctrl/)).to.not.exist
})
})