handler_test.go 944 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package complete
  2. import (
  3. "net/http"
  4. "testing"
  5. "github.com/cryptix/exp/multiModulePage/router"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestURLTo_index(t *testing.T) {
  9. setup(t)
  10. defer teardown()
  11. a := assert.New(t)
  12. url, err := router.CompleteApp().Get(router.CompleteIndex).URL()
  13. a.Nil(err)
  14. html, resp := testClient.GetHTML(url.String(), nil)
  15. a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code")
  16. a.Equal("<title>Complete - Index", html.Find("title").Text())
  17. }
  18. func TestURLTo_complete(t *testing.T) {
  19. setup(t)
  20. defer teardown()
  21. a := assert.New(t)
  22. url, err := router.CompleteApp().Get(router.FeedPost).URL("PostID", "1")
  23. a.Nil(err)
  24. html, resp := testClient.GetHTML(url.String(), nil)
  25. a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code")
  26. lnk, ok := html.Find("#overview").Attr("href")
  27. a.True(ok)
  28. a.Equal("/feed/", lnk)
  29. lnk, ok = html.Find("#next").Attr("href")
  30. a.True(ok)
  31. a.Equal("/feed/post/3", lnk)
  32. }