Fix chat notification highlight words split regex (#5798)

Fixes an issue where the chat notifications plugin would not split word highlights with input as `some,highlight` even though they are supposed to be valid
This commit is contained in:
Kamiel
2018-10-08 15:18:48 +02:00
committed by Tomas Slusny
parent 82bb383883
commit 44dcba2f10
2 changed files with 25 additions and 3 deletions

View File

@@ -24,9 +24,12 @@
*/
package net.runelite.client.plugins.chatnotifications;
import com.google.common.base.Splitter;
import com.google.inject.Guice;
import com.google.inject.testing.fieldbinder.Bind;
import com.google.inject.testing.fieldbinder.BoundFieldModule;
import java.util.Iterator;
import java.util.List;
import javax.inject.Inject;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
@@ -34,6 +37,7 @@ import net.runelite.api.MessageNode;
import net.runelite.api.events.SetMessage;
import net.runelite.client.Notifier;
import net.runelite.client.chat.ChatMessageManager;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -88,4 +92,19 @@ public class ChatNotificationsPluginTest
verify(messageNode).setValue("<colHIGHLIGHT>Deathbeam<colNORMAL>, <colHIGHLIGHT>Deathbeam<colNORMAL> OSRS");
}
@Test
public void highlightListTest()
{
when(config.highlightWordsString()).thenReturn("this,is, a , test, ");
final Splitter splitter = Splitter.on(",").trimResults().omitEmptyStrings();
final List<String> higlights = splitter.splitToList(config.highlightWordsString());
assertEquals(4, higlights.size());
final Iterator<String> iterator = higlights.iterator();
assertEquals("this", iterator.next());
assertEquals("is", iterator.next());
assertEquals("a", iterator.next());
assertEquals("test", iterator.next());
}
}