mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 01:57:02 +00:00
- Rename BUILD_DATE to BUILDDATE in goxc - Update travis config - Follow linter recommendations for inbucket.go - Follow linter recommendations for config package - Follow linter recommendations for log package - Follow linter recommendations for pop3d package - Follow linter recommendations for smtpd package - Follow linter recommendations for web package - Fix Id -> ID in templates - Add shebang to REST demo scripts - Add or refine many comments
31 lines
904 B
Go
31 lines
904 B
Go
package web
|
|
|
|
import (
|
|
"html/template"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestTextToHtml(t *testing.T) {
|
|
// Identity
|
|
assert.Equal(t, textToHTML("html"), template.HTML("html"))
|
|
|
|
// Check it escapes
|
|
assert.Equal(t, textToHTML("<html>"), template.HTML("<html>"))
|
|
|
|
// Check for linebreaks
|
|
assert.Equal(t, textToHTML("line\nbreak"), template.HTML("line<br/>\nbreak"))
|
|
assert.Equal(t, textToHTML("line\r\nbreak"), template.HTML("line<br/>\nbreak"))
|
|
assert.Equal(t, textToHTML("line\rbreak"), template.HTML("line<br/>\nbreak"))
|
|
}
|
|
|
|
func TestURLDetection(t *testing.T) {
|
|
assert.Equal(t,
|
|
textToHTML("http://google.com/"),
|
|
template.HTML("<a href=\"http://google.com/\" target=\"_blank\">http://google.com/</a>"))
|
|
assert.Equal(t,
|
|
textToHTML("http://a.com/?q=a&n=v"),
|
|
template.HTML("<a href=\"http://a.com/?q=a&n=v\" target=\"_blank\">http://a.com/?q=a&n=v</a>"))
|
|
}
|