This repository has been archived by the owner on Nov 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix counter continue in highlighted-fence-replacer.tsx (#943)
Signed-off-by: Tilman Vatteroth <[email protected]>
- Loading branch information
1 parent
7be64bc
commit 9f6b1a9
Showing
5 changed files
with
197 additions
and
117 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
describe('Code', () => { | ||
beforeEach(() => { | ||
cy.visit('/n/test', { | ||
onBeforeLoad (win: Window): void { | ||
cy.spy(win.navigator.clipboard, 'writeText').as('copy') | ||
} | ||
}) | ||
cy.get('.btn.active.btn-outline-secondary > i.fa-columns') | ||
.should('exist') | ||
|
||
cy.get('.CodeMirror ') | ||
.click() | ||
cy.get('.CodeMirror textarea') | ||
.as('codeinput') | ||
}) | ||
|
||
describe('with just the language', () => { | ||
it('doesn\'t show a gutter', () => { | ||
cy.get('@codeinput') | ||
.fill('```javascript \nlet x = 0\n```') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.should('be.visible') | ||
.should('not.have.class', 'showGutter') | ||
cy.get('.markdown-body > pre > code.hljs > .linenumber') | ||
.should('not.be.visible') | ||
}) | ||
|
||
describe('and line wrapping', () => { | ||
it('doesn\'t show a gutter', () => { | ||
cy.get('@codeinput') | ||
.fill('```javascript! \nlet x = 0\n```') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.should('be.visible') | ||
.should('not.have.class', 'showGutter') | ||
.should('have.class', 'wrapLines') | ||
cy.get('.markdown-body > pre > code.hljs > .linenumber') | ||
.should('not.be.visible') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('with the language and show gutter', () => { | ||
it('shows the correct line number', () => { | ||
cy.get('@codeinput') | ||
.fill('```javascript= \nlet x = 0\n```') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.should('be.visible') | ||
.should('have.class', 'showGutter') | ||
cy.get('.markdown-body > pre > code.hljs > .linenumber') | ||
.should('be.visible') | ||
.text() | ||
.should('eq', '1') | ||
}) | ||
|
||
describe('and line wrapping', () => { | ||
it('shows the correct line number', () => { | ||
cy.get('@codeinput') | ||
.fill('```javascript=! \nlet x = 0\n```') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.should('be.visible') | ||
.should('have.class', 'showGutter') | ||
.should('have.class', 'wrapLines') | ||
cy.get('.markdown-body > pre > code.hljs > .linenumber') | ||
.should('be.visible') | ||
.text() | ||
.should('eq', '1') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('with the language, show gutter with a start number', () => { | ||
it('shows the correct line number', () => { | ||
cy.get('@codeinput') | ||
.fill('```javascript=100 \nlet x = 0\n```') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.should('be.visible') | ||
.should('have.class', 'showGutter') | ||
cy.get('.markdown-body > pre > code.hljs > .linenumber') | ||
.should('be.visible') | ||
.text() | ||
.should('eq', '100') | ||
}) | ||
|
||
it('shows the correct line number and continues in another codeblock', () => { | ||
cy.get('@codeinput') | ||
.fill('```javascript=100 \nlet x = 0\nlet y = 1\n```\n\n```javascript=+\nlet y = 2\n```\n') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.should('be.visible') | ||
.should('have.class', 'showGutter') | ||
.first() | ||
.find('.linenumber') | ||
.first() | ||
.should('be.visible') | ||
.text() | ||
.should('eq', '100') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.first() | ||
.find('.linenumber') | ||
.last() | ||
.should('be.visible') | ||
.text() | ||
.should('eq', '101') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.last() | ||
.find('.linenumber') | ||
.first() | ||
.should('be.visible') | ||
.text() | ||
.should('eq', '102') | ||
}) | ||
|
||
describe('and line wrapping', () => { | ||
it('shows the correct line number', () => { | ||
cy.get('@codeinput') | ||
.fill('```javascript=100! \nlet x = 0\n```') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.should('be.visible') | ||
.should('have.class', 'showGutter') | ||
.should('have.class', 'wrapLines') | ||
cy.get('.markdown-body > pre > code.hljs > .linenumber') | ||
.should('be.visible') | ||
.text() | ||
.should('eq', '100') | ||
}) | ||
|
||
it('shows the correct line number and continues in another codeblock', () => { | ||
cy.get('@codeinput') | ||
.fill('```javascript=100! \nlet x = 0\nlet y = 1\n```\n\n```javascript=+\nlet y = 2\n```\n') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.should('be.visible') | ||
.should('have.class', 'showGutter') | ||
.should('have.class', 'wrapLines') | ||
.first() | ||
.find('.linenumber') | ||
.first() | ||
.should('be.visible') | ||
.text() | ||
.should('eq', '100') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.first() | ||
.find('.linenumber') | ||
.last() | ||
.should('be.visible') | ||
.text() | ||
.should('eq', '101') | ||
cy.get('.markdown-body > pre > code.hljs') | ||
.last() | ||
.find('.linenumber') | ||
.first() | ||
.should('be.visible') | ||
.text() | ||
.should('eq', '102') | ||
}) | ||
}) | ||
}) | ||
|
||
it('has a working copy button', () => { | ||
cy.get('@codeinput') | ||
.fill('```javascript \nlet x = 0\n```') | ||
cy.get('.markdown-body > pre > div > button > i') | ||
.should('have.class', 'fa-files-o') | ||
.click() | ||
cy.get('@copy').should('be.calledWithExactly', 'let x = 0\n') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters