package chat
import (
	"testing"
	"github.com/owncast/owncast/core/chat/events"
)
// Test a bunch of arbitrary markup and markdown to make sure we get sanitized
// and fully rendered HTML out of it.
func TestRenderAndSanitize(t *testing.T) {
	messageContent := `
  Test one two three!  I go to http://yahoo.com and search for _sports_ and **answers**.
  Here is an iframe 
  ## blah blah blah
  [test link](http://owncast.online)
  
  
  `
	expected := `Test one two three!  I go to http://yahoo.com and search for sports and answers.
Here is an iframe 
blah blah blah
test link
`
	result := events.RenderAndSanitize(messageContent)
	if result != expected {
		t.Errorf("message rendering/sanitation does not match expected.  Got\n%s, \n\n want:\n%s", result, expected)
	}
}
// Test to make sure we block remote images in chat messages.
func TestBlockRemoteImages(t *testing.T) {
	messageContent := ` test `
	expected := `test`
	result := events.RenderAndSanitize(messageContent)
	if result != expected {
		t.Errorf("message rendering/sanitation does not match expected.  Got\n%s, \n\n want:\n%s", result, expected)
	}
}
// Test to make sure emoji images are allowed in chat messages.
func TestAllowEmojiImages(t *testing.T) {
	messageContent := `
 test `
	expected := `
 test 
`
	result := events.RenderAndSanitize(messageContent)
	if result != expected {
		t.Errorf("message rendering/sanitation does not match expected.  Got\n%s, \n\n want:\n%s", result, expected)
	}
}
// Test to verify we can pass raw html and render markdown.
func TestAllowHTML(t *testing.T) {
	messageContent := `
