Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10 #11

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/test/java/com/fewlaps/mentiondetector/GetMentionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,53 @@ public void shouldReturnEmpty_whenPassingATextWithAnEmail_atTheEnd() throws Inte
List<Mention> mentions = new MentionDetector(text).getMentions();
assertThat(mentions).isEmpty();
}

@Test
public void shouldReturnNickDot_whenPassingATextWithMentionWithDot_atTheEnd() throws InterruptedException {
String text = "Hello @nick.";
String username = new MentionDetector(text).getMentions().get(0).usernameWithoutAtSymbol();
assertThat(username).isEqualTo("nick.");
}

@Test
public void shouldReturnDashNick_whenPassingATextWithMentionWithDash_atTheStart() throws InterruptedException {
String text = "Hello @-nick";
String username = new MentionDetector(text).getMentions().get(0).usernameWithoutAtSymbol();
assertThat(username).isEqualTo("-nick");
}

@Test
public void shouldReturnNick_whenPassingATextWithMentionWithExclamation_atTheEnd() throws InterruptedException {
String text = "Hello @nick!";
String username = new MentionDetector(text).getMentions().get(0).usernameWithoutAtSymbol();
assertThat(username).isEqualTo("nick");
}

@Test
public void shouldNotReturnMentions_whenPassingATextWithMentionWithExclamation_atTheStart() throws InterruptedException {
String text = "Hello @!nick";
List<Mention> mentions = new MentionDetector(text).getMentions();
assertThat(mentions).isEmpty();
}

@Test
public void shouldNotReturnMentions_whenPassingATextWithMentionWithSpace_atTheStart() throws InterruptedException {
String text = "Hello @ nick";
List<Mention> mentions = new MentionDetector(text).getMentions();
assertThat(mentions).isEmpty();
}

@Test
public void shouldNotReturnMentions_whenPassingATextWithMentionWithSymbol_atTheMiddle() throws InterruptedException {
String text = "Hello nick@nick";
List<Mention> mentions = new MentionDetector(text).getMentions();
assertThat(mentions).isEmpty();
}

@Test
public void shouldNotReturnMentions_whenPassingATextWithMentionWithMentionSymbol_atTheStartAndEnd() throws InterruptedException {
String text = "Hello @nick@";
List<Mention> mentions = new MentionDetector(text).getMentions();
assertThat(mentions).isEmpty();
}
}