diff options
author | desperateCoder <echotodevnull@gmail.com> | 2020-09-04 16:18:18 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-09-04 20:03:12 +0300 |
commit | b53b63c14aa030197a666443b7ad227dd8529c2a (patch) | |
tree | 508835dabbceb752b29fa28683e0719e5bcce261 /app/src/test/java/it/niedermann/nextcloud/deck | |
parent | 7378f7e652eb57fde4be04fa241966fd053648f7 (diff) |
#673 discover mentions
Diffstat (limited to 'app/src/test/java/it/niedermann/nextcloud/deck')
-rw-r--r-- | app/src/test/java/it/niedermann/nextcloud/deck/CommentsUtilTest.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/src/test/java/it/niedermann/nextcloud/deck/CommentsUtilTest.java b/app/src/test/java/it/niedermann/nextcloud/deck/CommentsUtilTest.java new file mode 100644 index 000000000..65056b798 --- /dev/null +++ b/app/src/test/java/it/niedermann/nextcloud/deck/CommentsUtilTest.java @@ -0,0 +1,41 @@ +package it.niedermann.nextcloud.deck; + +import org.junit.Assert; +import org.junit.Test; + +import it.niedermann.nextcloud.deck.ui.card.comments.util.CommentsUtil; + +public class CommentsUtilTest { + + @Test + public void testMentionDiscovery() { + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("", 0)); + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("a ", 1)); + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("a ", 2)); + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("@a ", 3)); + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("d@a", 2)); + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("d@a", 0)); + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("d@a", 3)); + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("ab", 0)); + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("ab", 1)); + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("ab", 2)); + Assert.assertNull(CommentsUtil.getUserNameForMentionProposal("def @ab ", 8)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("\n@ab", 3)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("\n@ab", 4)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("\t@ab", 3)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal(" @ab", 3)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("@ab", 3)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("@ab", 2)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("@ab def", 2)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("@ab def", 3)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("def @ab ", 5)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("def @ab", 6)); + Assert.assertEquals("ab_asdf_ldklsdkf", CommentsUtil.getUserNameForMentionProposal("def @ab_asdf_ldklsdkf", 7)); + Assert.assertEquals("ab_asdf_ldklsdkf", CommentsUtil.getUserNameForMentionProposal("def @ab_asdf_ldklsdkf ", 7)); + Assert.assertEquals("\"ab_asdf_ldklsdkf\"", CommentsUtil.getUserNameForMentionProposal("def @\"ab_asdf_ldklsdkf\"", 7)); + Assert.assertEquals("\"ab_asdf_ldklsdkf\"", CommentsUtil.getUserNameForMentionProposal("def @\"ab_asdf_ldklsdkf\" \nasdf", 7)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("def @ab\n", 7)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("\ndef @ab\n", 8)); + Assert.assertEquals("ab", CommentsUtil.getUserNameForMentionProposal("\n def @ab\nasdfasdf", 9)); + } +} |