diff -r d436b88d137b -r 7d712d2bde73 printer/html2text/html2text_test.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/printer/html2text/html2text_test.go Fri May 12 23:31:21 2017 +0200 @@ -0,0 +1,177 @@ +package html2text + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +func TestTextify(t *testing.T) { + expected := "body\nbody2" + r, e := Textify("
bodyJoin by phone |
1-877-668-4490 Call-in toll-free number (US/Canada) |
1-408-792-6300 Call-in toll number (US/Canada) |
Access code: 111 111 111 |
Global call-in numbers | Toll-free calling restrictions |
@cadey It looks good at first glance
"case <-stop" Actually you don't listen to stop channel, you close it if you want to stop the listener.
` + + r, e := Textify(body) + assert.Nil(t, e) + assert.Equal(t, expected, r) +} + +func TestTextifyMastodonSample3(t *testing.T) { + expected := "From timeline: Materials research creates potential for improved computer chips and transistors #phys #physics ..." + + body := `From timeline: Materials research creates potential for improved computer chips and transistors #phys #physics...
` + + r, e := Textify(body) + assert.Nil(t, e) + assert.Equal(t, expected, r) +} + +func TestTextifyMastodonSample4(t *testing.T) { + expected := "Vous reprendrez bien un peu de #Tolkein ?\n#Arte +7 propose un ensemble de 6 vidéos en plus du documentaire:\nhttp://www.arte.tv/fr/videos/RC-014610/tolkien/" + + body := `Vous reprendrez bien un peu de #Tolkein ?
#Arte+7 propose un ensemble de 6 vidéos en plus du documentaire:
http://www.arte.tv/fr/videos/RC-014610/tolkien/
` + + r, e := Textify(body) + assert.Nil(t, e) + assert.Equal(t, expected, r) +} + +func TestTextifyMastodonMentionAndTag(t *testing.T) { + expected := "@ACh Mais heu ! Moi aussi je fais du #TootRadio de gens morts il y a 5 siècles. Gesulado, Charpentier, Mireille Mathieu..." + + body := `@ACh Mais heu ! Moi aussi je fais du #TootRadio de gens morts il y a 5 siècles. Gesulado, Charpentier, Mireille Mathieu...
` + + r, e := Textify(body) + assert.Nil(t, e) + assert.Equal(t, expected, r) +} + +func TestTextifyMastodonLinkSpacing(t *testing.T) { + expected := "\"Twitter\" https://twitter.com/holly/status/123456789012345678" + + body := `"Twitter" https://twitter.com/holly/status/862661234567890123
` + + r, e := Textify(body) + assert.Nil(t, e) + assert.Equal(t, expected, r) +} + +func TestTextifyMastodonMentionGNUSocial(t *testing.T) { + expected := "@username Hello." + + body := `@username Hello.` + + r, e := Textify(body) + assert.Nil(t, e) + assert.Equal(t, expected, r) +}