plaintext_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package plaintext
  2. import (
  3. "servitor/ansi"
  4. "servitor/style"
  5. "testing"
  6. )
  7. func TestBasic(t *testing.T) {
  8. input := `Yes, Jim, I found it under "http://www.w3.org/Addressing/",
  9. but you can probably pick it up from the store.
  10. Note the warning in <http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING>.`
  11. markup, links, err := NewMarkup(input)
  12. if err != nil {
  13. t.Fatal(err)
  14. }
  15. output := markup.Render(50)
  16. first := links[0]
  17. if first != "http://www.w3.org/Addressing/" {
  18. t.Fatalf("first uri should be http://www.w3.org/Addressing/ not %s", first)
  19. }
  20. second := links[1]
  21. if second != "http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING" {
  22. t.Fatalf("first uri should be http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING not %s", second)
  23. }
  24. expected := ansi.Wrap("Yes, Jim, I found it under \""+style.Link("http://www.w3.org/Addressing/", 1)+
  25. "\",\nbut you can probably pick it up from the store.\n"+
  26. "Note the warning in <"+style.Link("http://www.ics.uci.edu/pub/ietf/uri/historical.html#WARNING", 2)+">.", 50)
  27. if expected != output {
  28. t.Fatalf("expected markup to be %s not %s", expected, output)
  29. }
  30. }