/t/t-ajax.lisp

http://github.com/mtravers/wuwei · Lisp · 41 lines · 24 code · 13 blank · 4 comment · 0 complexity · 4ce5eae80e75547be59b4dce37970d54 MD5 · raw file

  1. (in-package :wu)
  2. (5am:def-suite :ajax :in :wuwei)
  3. (5am:in-suite :ajax)
  4. (defparameter *test-port* 8003)
  5. ;;; aserve started acting hincky in ccl, so this stops working if it is called >1 time...or something like that.
  6. (net.aserve:start :port *test-port*)
  7. (defun test-url (s)
  8. (format nil "http://localhost:~A/tests/~A" *test-port* s))
  9. (defun test-path (s)
  10. (string+ "/tests/" s))
  11. ;;; Tests for basic Ajax machinery and update generation
  12. ;;; Test that the generation machinery is sane
  13. (5am:test generation
  14. (5am:is
  15. (typep
  16. (html-string
  17. (link-to-remote "foo" "/foo" :html-options '(:style "font-style:italic") :success "alert('you win');"))
  18. 'string)))
  19. (defparameter *ajax-test-url* (format nil "http://localhost:~A" *test-port*))
  20. ;;; Tests ajax-continuation mechanism via GET-URL
  21. (5am:test ajax
  22. (let ((test nil))
  23. (get-url (string+ *ajax-test-url*
  24. (ajax-continuation ()
  25. (setq test t)
  26. (render-update (:alert "foo"))))
  27. :method :post)
  28. (5am:is-true test)))