From 22dbde70bca429a6913d072888e9c31679069406 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 26 Jul 2022 09:59:05 +0200 Subject: Added tests for the front matter node Signed-off-by: Ferdinand Thiessen --- cypress/e2e/FrontMatter.spec.js | 62 +++++++++++++++++++++++++++++++++++++++++ cypress/fixtures/frontmatter.md | 6 ++++ 2 files changed, 68 insertions(+) create mode 100644 cypress/e2e/FrontMatter.spec.js create mode 100644 cypress/fixtures/frontmatter.md (limited to 'cypress') diff --git a/cypress/e2e/FrontMatter.spec.js b/cypress/e2e/FrontMatter.spec.js new file mode 100644 index 000000000..1a7200779 --- /dev/null +++ b/cypress/e2e/FrontMatter.spec.js @@ -0,0 +1,62 @@ +/** + * @copyright Copyright (c) 2022 + * + * @license AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +import { initUserAndFiles, randHash } from '../utils/index.js' + +const randUser = randHash() + +describe('Front matter support', function() { + before(function() { + initUserAndFiles(randUser, 'frontmatter.md', 'empty.md') + }) + + beforeEach(function() { + cy.login(randUser, 'password') + }) + + it('Open file with front matter', function() { + cy.openFile('frontmatter.md').then(() => { + expect(cy.getContent().find('pre.frontmatter').length === 1) + }) + }) + + it('Add front matter', function() { + cy.openFile('empty.md').clearContent().then(() => { + cy.getContent() + .type('---') + .type('test') + cy.getContent().find('pre.frontmatter').should(pre => { + expect(pre.length === 1) + expect(pre[0].text === 'test') + }) + }) + }) + + it('Do not add multiple front matter', function() { + cy.openFile('empty.md').clearContent().then(() => { + cy.getContent() + .type('---test') + .type('{downArrow}') + .type('---test') + cy.getContent().find('pre.frontmatter').should(pre => expect(pre.length === 1)) + cy.getContent().find('hr').should(hr => expect(hr.length === 1)) + }) + }) +}) diff --git a/cypress/fixtures/frontmatter.md b/cypress/fixtures/frontmatter.md new file mode 100644 index 000000000..5698c55c5 --- /dev/null +++ b/cypress/fixtures/frontmatter.md @@ -0,0 +1,6 @@ +--- +some: value +other: 1.2 +--- +# Heading +Content \ No newline at end of file -- cgit v1.2.3