BookStack/tests/Entity/MarkdownTest.php

54 lines
1.4 KiB
PHP
Raw Normal View History

2021-06-26 11:23:15 -04:00
<?php
namespace Tests\Entity;
use Tests\BrowserKitTest;
2017-01-25 14:35:40 -05:00
class MarkdownTest extends BrowserKitTest
{
protected $page;
2019-09-13 18:58:40 -04:00
public function setUp(): void
{
parent::setUp();
$this->page = \BookStack\Entities\Models\Page::first();
}
protected function setMarkdownEditor()
{
$this->setSettings(['app-editor' => 'markdown']);
}
public function test_default_editor_is_wysiwyg()
{
$this->assertEquals(setting('app-editor'), 'wysiwyg');
$this->asAdmin()->visit($this->page->getUrl() . '/edit')
->pageHasElement('#html-editor');
}
2021-06-26 11:23:15 -04:00
public function test_markdown_setting_shows_markdown_editor()
{
$this->setMarkdownEditor();
$this->asAdmin()->visit($this->page->getUrl() . '/edit')
->pageNotHasElement('#html-editor')
->pageHasElement('#markdown-editor');
}
public function test_markdown_content_given_to_editor()
{
$this->setMarkdownEditor();
$mdContent = '# hello. This is a test';
$this->page->markdown = $mdContent;
$this->page->save();
$this->asAdmin()->visit($this->page->getUrl() . '/edit')
->seeInField('markdown', $mdContent);
}
public function test_html_content_given_to_editor_if_no_markdown()
{
$this->setMarkdownEditor();
$this->asAdmin()->visit($this->page->getUrl() . '/edit')
->seeInField('markdown', $this->page->html);
}
2021-06-26 11:23:15 -04:00
}