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:
35
cypress/integration/examples/code-highlighting.ts
Normal file
35
cypress/integration/examples/code-highlighting.ts
Normal 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)')
|
||||||
|
})
|
||||||
|
})
|
Reference in New Issue
Block a user