1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 10:29:48 +02:00

Added cypress-test for code-highlighting (#4409)

* Added cypress-test for code-highlighting

* moved the codeHighlighting.ts example to the examples folder
This commit is contained in:
Anish Aggarwal
2021-08-03 17:32:54 +05:30
committed by GitHub
parent a35fe46bff
commit 97b280926c
3 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
describe('code highlighting', () => {
const slateEditor = '[data-slate-node="element"]'
const leafNode = 'span[data-slate-leaf="true"]'
beforeEach(() => {
cy.visit('examples/code-highlighting')
})
it('highlights HTML tags', () => {
cy.get(slateEditor)
.find('span')
.eq(0)
.find(leafNode)
.eq(0)
.should('contain', '<h1>')
.should('have.css', 'color', 'rgb(153, 0, 85)')
})
it('highlights javascript syntax', () => {
const JSCode = 'const slateVar = 30;{enter}'
cy.get('select').select('JavaScript') // Select the 'JavaScript' option
cy.get(slateEditor)
.type('{movetostart}')
.type(JSCode) // Type JavaScript code
cy.get(slateEditor)
.find('span')
.eq(0)
.find(leafNode)
.eq(0)
.should('contain', 'const')
.should('have.css', 'color', 'rgb(0, 119, 170)')
})
})