mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00
Upgrade to CodeMirror 6 (#1787)
Upgrade to CodeMirror 6 Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
1a09bfa5f1
commit
6a6f6105b9
103 changed files with 1906 additions and 2615 deletions
|
@ -4,11 +4,6 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
const TEST_STRING_UNCHECKED = '- [ ] abc\n\n* [ ] abc\n\n+ [ ] abc\n\n1. [ ] abc\n\n10. [ ] abc\n\n5) [ ] abc'
|
||||
const TEST_STRING_CHECKED_LOWER = '- [x] abc\n\n* [x] abc\n\n+ [x] abc\n\n1. [x] abc\n\n10. [x] abc\n\n5) [x] abc'
|
||||
const TEST_STRING_CHECKED_UPPER = '- [X] abc\n\n* [X] abc\n\n+ [X] abc\n\n1. [X] abc\n\n10. [X] abc\n\n5) [X] abc'
|
||||
const TEST_STRING_INVALID = '- [Y] abc\n\n* [ ] abc\n\n+ [-] abc\n\n1. [.] abc\n\n10. [] abc\n\n5) [-] abc'
|
||||
|
||||
describe('Task lists ', () => {
|
||||
beforeEach(() => {
|
||||
cy.visitTestNote()
|
||||
|
@ -16,55 +11,55 @@ describe('Task lists ', () => {
|
|||
|
||||
describe('render with checkboxes ', () => {
|
||||
it('when unchecked', () => {
|
||||
cy.setCodemirrorContent(TEST_STRING_UNCHECKED)
|
||||
cy.setCodemirrorContent('- [ ] abc\n\n* [ ] abc\n\n+ [ ] abc\n\n1. [ ] abc\n\n10. [ ] abc\n\n5) [ ] abc')
|
||||
cy.getMarkdownBody().find('input[type=checkbox]').should('have.length', 6)
|
||||
})
|
||||
|
||||
it('when checked lowercase', () => {
|
||||
cy.setCodemirrorContent(TEST_STRING_CHECKED_LOWER)
|
||||
cy.setCodemirrorContent('- [x] abc\n\n* [x] abc\n\n+ [x] abc\n\n1. [x] abc\n\n10. [x] abc\n\n5) [x] abc')
|
||||
cy.getMarkdownBody().find('input[type=checkbox]').should('have.length', 6)
|
||||
})
|
||||
|
||||
it('when checked uppercase', () => {
|
||||
cy.setCodemirrorContent(TEST_STRING_CHECKED_UPPER)
|
||||
cy.setCodemirrorContent('- [X] abc\n\n* [X] abc\n\n+ [X] abc\n\n1. [X] abc\n\n10. [X] abc\n\n5) [X] abc')
|
||||
cy.getMarkdownBody().find('input[type=checkbox]').should('have.length', 6)
|
||||
})
|
||||
})
|
||||
|
||||
it('do not render as checkboxes when invalid', () => {
|
||||
cy.setCodemirrorContent(TEST_STRING_INVALID)
|
||||
cy.setCodemirrorContent('- [Y] abc\n\n* [ ] abc\n\n+ [-] abc\n\n1. [.] abc\n\n10. [] abc\n\n5) [-] abc')
|
||||
cy.getMarkdownBody().find('input[type=checkbox]').should('have.length', 0)
|
||||
})
|
||||
|
||||
describe('are clickable and change the markdown source ', () => {
|
||||
it('from unchecked to checked', () => {
|
||||
cy.setCodemirrorContent(TEST_STRING_UNCHECKED)
|
||||
cy.setCodemirrorContent('- [ ] abc')
|
||||
cy.getMarkdownBody()
|
||||
.find('input[type=checkbox]')
|
||||
.each((box) => {
|
||||
box.trigger('click')
|
||||
box.click()
|
||||
})
|
||||
cy.get('.CodeMirror-line > span').should('exist').should('contain.text', '[x]').should('not.contain.text', '[ ]')
|
||||
cy.get('.cm-editor .cm-line').first().should('contain.text', '[x]').should('not.contain.text', '[ ]')
|
||||
})
|
||||
|
||||
it('from checked (lowercase) to unchecked', () => {
|
||||
cy.setCodemirrorContent(TEST_STRING_CHECKED_LOWER)
|
||||
cy.setCodemirrorContent('- [x] abc')
|
||||
cy.getMarkdownBody()
|
||||
.find('input[type=checkbox]')
|
||||
.each((box) => {
|
||||
box.trigger('click')
|
||||
box.click()
|
||||
})
|
||||
cy.get('.CodeMirror-line > span').should('exist').should('contain.text', '[ ]').should('not.contain.text', '[x]')
|
||||
cy.get('.cm-editor .cm-line').should('exist').should('contain.text', '[ ]').should('not.contain.text', '[x]')
|
||||
})
|
||||
|
||||
it('from checked (uppercase) to unchecked', () => {
|
||||
cy.setCodemirrorContent(TEST_STRING_CHECKED_UPPER)
|
||||
cy.setCodemirrorContent('- [X] abc')
|
||||
cy.getMarkdownBody()
|
||||
.find('input[type=checkbox]')
|
||||
.each((box) => {
|
||||
box.trigger('click')
|
||||
box.click()
|
||||
})
|
||||
cy.get('.CodeMirror-line > span').should('exist').should('contain.text', '[ ]').should('not.contain.text', '[X]')
|
||||
cy.get('.cm-editor .cm-line').should('exist').should('contain.text', '[ ]').should('not.contain.text', '[X]')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue