<div class="editor-toolbar">
<div class="">Preview</div>
</div>
- <div class="markdown-display page-content" ng-bind-html="displayContent"></div>
+ <div class="markdown-display">
+ <div class="page-content" ng-bind-html="displayContent"></div>
+ </div>
</div>
</div>
--- /dev/null
+<?php
+
+
+class MarkdownTest extends TestCase
+{
+ protected $page;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->page = \BookStack\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');
+ }
+
+ 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);
+ }
+
+}
\ No newline at end of file
$this->visit($link->link()->getUri());
return $this;
}
+
+ /**
+ * Check if the page contains the given element.
+ * @param string $selector
+ * @return bool
+ */
+ protected function pageHasElement($selector)
+ {
+ $elements = $this->crawler->filter($selector);
+ $this->assertTrue(count($elements) > 0, "The page does not contain an element matching " . $selector);
+ return $this;
+ }
+
+ /**
+ * Check if the page contains the given element.
+ * @param string $selector
+ * @return bool
+ */
+ protected function pageNotHasElement($selector)
+ {
+ $elements = $this->crawler->filter($selector);
+ $this->assertFalse(count($elements) > 0, "The page contains " . count($elements) . " elements matching " . $selector);
+ return $this;
+ }
}