|
| 1 | +/** |
| 2 | + * @copyright Copyright (c) 2022 |
| 3 | + * |
| 4 | + * @license AGPL-3.0-or-later |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU Affero General Public License as |
| 8 | + * published by the Free Software Foundation, either version 3 of the |
| 9 | + * License, or (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU Affero General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Affero General Public License |
| 17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + * |
| 19 | + */ |
| 20 | + |
| 21 | +import { initUserAndFiles, randHash } from '../utils/index.js' |
| 22 | + |
| 23 | +const randUser = randHash() |
| 24 | + |
| 25 | +describe('Front matter support', function() { |
| 26 | + before(function() { |
| 27 | + initUserAndFiles(randUser, 'frontmatter.md', 'empty.md') |
| 28 | + }) |
| 29 | + |
| 30 | + beforeEach(function() { |
| 31 | + cy.login(randUser, 'password') |
| 32 | + }) |
| 33 | + |
| 34 | + it('Open file with front matter', function() { |
| 35 | + cy.openFile('frontmatter.md').then(() => { |
| 36 | + expect(cy.getContent().find('pre.frontmatter').length === 1) |
| 37 | + }) |
| 38 | + }) |
| 39 | + |
| 40 | + it('Add front matter', function() { |
| 41 | + cy.openFile('empty.md').clearContent().then(() => { |
| 42 | + cy.getContent() |
| 43 | + .type('---') |
| 44 | + .type('test') |
| 45 | + cy.getContent().find('pre.frontmatter').should(pre => { |
| 46 | + expect(pre.length === 1) |
| 47 | + expect(pre[0].text === 'test') |
| 48 | + }) |
| 49 | + }) |
| 50 | + }) |
| 51 | + |
| 52 | + it('Do not add multiple front matter', function() { |
| 53 | + cy.openFile('empty.md').clearContent().then(() => { |
| 54 | + cy.getContent() |
| 55 | + .type('---test') |
| 56 | + .type('{downArrow}') |
| 57 | + .type('---test') |
| 58 | + cy.getContent().find('pre.frontmatter').should(pre => expect(pre.length === 1)) |
| 59 | + cy.getContent().find('hr').should(hr => expect(hr.length === 1)) |
| 60 | + }) |
| 61 | + }) |
| 62 | +}) |
0 commit comments