Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/TextTest.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/TextTest.php b/tests/TextTest.php
index 79376212e..aeaa8d0cc 100644
--- a/tests/TextTest.php
+++ b/tests/TextTest.php
@@ -3,10 +3,35 @@
namespace OCA\Text\Tests;
use OCA\Text\AppInfo\Application;
+use OCA\Text\Service\ImageService;
class TextTest extends \PHPUnit\Framework\TestCase {
public function testDummy() {
$app = new Application();
$this->assertEquals('text', $app::APP_NAME);
}
+
+ public function testGetAttachmentNamesFromContent() {
+ $contentNames = [
+ 'aaa.png',
+ 'a[a]a.png',
+ 'a(a)a.png',
+ 'a](a.png',
+ ',;:!?.ยง-_a_',
+ 'a`a`.png',
+ ];
+ $content = "some content\n";
+ foreach ($contentNames as $name) {
+ // this is how it's generated in MenuBar.vue
+ $linkText = preg_replace('/[[\]]/', '', $name);
+ $encodedName = urlencode($name);
+ $content .= '![' . $linkText . '](text://image?imageFileName=' . $encodedName . ")\n";
+ }
+ $content .= 'some content';
+
+ $computedNames = ImageService::getAttachmentNamesFromContent($content);
+ foreach ($contentNames as $contentName) {
+ $this->assertContains($contentName, $computedNames);
+ }
+ }
}