helpers_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package helpers_test
  2. import (
  3. "testing"
  4. . "github.com/onsi/ginkgo"
  5. . "github.com/onsi/gomega"
  6. "github.com/vladimirok5959/golang-utils/utils/http/helpers"
  7. )
  8. var _ = Describe("helpers", func() {
  9. Context("MinifyHtmlCode", func() {
  10. It("minify Html code", func() {
  11. Expect(helpers.MinifyHtmlCode(`
  12. <!doctype html>
  13. <html lang="uk">
  14. <head>
  15. <meta charset="utf-8" />
  16. </head>
  17. <body>
  18. Index
  19. </body>
  20. </html>
  21. `)).To(Equal(`<!doctype html><html lang="uk"><head><meta charset="utf-8" /></head><body>Index</body></html>`))
  22. Expect(helpers.MinifyHtmlCode(`
  23. <div>
  24. <a href="#">Link 1</a>, <a href="#">Link 2</a>
  25. </div>
  26. `)).To(Equal(`<div><a href="#">Link 1</a>, <a href="#">Link 2</a></div>`))
  27. Expect(helpers.MinifyHtmlCode(`
  28. <div>
  29. <b>Contacts:</b> <a href="#">Link 1</a>, <a href="#">Link 2</a>
  30. </div>
  31. `)).To(Equal(`<div><b>Contacts:</b> <a href="#">Link 1</a>, <a href="#">Link 2</a></div>`))
  32. })
  33. })
  34. })
  35. func TestSuite(t *testing.T) {
  36. RegisterFailHandler(Fail)
  37. RunSpecs(t, "helpers")
  38. }