Fixed comma appended to username completion when not at the beginning of the message (#3060)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Paweł
2021-07-24 12:01:50 +02:00
committed by GitHub
parent ae9f92ded9
commit 588ed557f0
13 changed files with 97 additions and 22 deletions
+22
View File
@@ -0,0 +1,22 @@
#include "util/Helpers.hpp"
#include <gtest/gtest.h>
using namespace chatterino;
TEST(Helpers, formatUserMention)
{
const auto userName = "pajlada";
// A user mention that is the first word, that has 'mention with comma' enabled should have a comma appended at the end.
EXPECT_EQ(formatUserMention(userName, true, true), "pajlada,");
// A user mention that is not the first word, but has 'mention with comma' enabled should not have a comma appended at the end.
EXPECT_EQ(formatUserMention(userName, false, true), "pajlada");
// A user mention that is the first word, but has 'mention with comma' disabled should not have a comma appended at the end.
EXPECT_EQ(formatUserMention(userName, true, false), "pajlada");
// A user mention that is neither the first word, nor has 'mention with comma' enabled should not have a comma appended at the end.
EXPECT_EQ(formatUserMention(userName, false, false), "pajlada");
}