]> BookStack Code Mirror - bookstack/blob - tests/Entity/MarkdownTest.php
eaf4d62c3ec9d964f38e91c1bc5db7f47c2086ef
[bookstack] / tests / Entity / MarkdownTest.php
1 <?php
2
3
4 class MarkdownTest extends TestCase
5 {
6     protected $page;
7
8     public function setUp()
9     {
10         parent::setUp();
11         $this->page = \BookStack\Page::first();
12     }
13
14     protected function setMarkdownEditor()
15     {
16         $this->setSettings(['app-editor' => 'markdown']);
17     }
18
19     public function test_default_editor_is_wysiwyg()
20     {
21         $this->assertEquals(setting('app-editor'), 'wysiwyg');
22         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
23             ->pageHasElement('#html-editor');
24     }
25     
26     public function test_markdown_setting_shows_markdown_editor()
27     {
28         $this->setMarkdownEditor();
29         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
30             ->pageNotHasElement('#html-editor')
31             ->pageHasElement('#markdown-editor');
32     }
33
34     public function test_markdown_content_given_to_editor()
35     {
36         $this->setMarkdownEditor();
37         $mdContent = '# hello. This is a test';
38         $this->page->markdown = $mdContent;
39         $this->page->save();
40         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
41             ->seeInField('markdown', $mdContent);
42     }
43
44     public function test_html_content_given_to_editor_if_no_markdown()
45     {
46         $this->setMarkdownEditor();
47         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
48             ->seeInField('markdown', $this->page->html);
49     }
50
51 }