~pepe/trolley

df8a91f7f28293e4aa993ea73f89a86b8048672d — Josef Pospíšil 4 years ago dba6357
Rename files
3 files changed, 10 insertions(+), 10 deletions(-)

M project.janet
R src/{router.janet => trolley.janet}
R test/{router.janet => trolley.janet}
M project.janet => project.janet +3 -3
@@ 1,11 1,11 @@
(declare-project
  :name "trolley"
  :description "General router"
  :dependencies ["https://github.com/joy-framework/tester"]
	:author "Josef Pospíšil"
  :license "MIT"
  :url "https://github.com/pepe/trolley"
  :repo "git+https://github.com/pepe/trolley")
  :repo "git+https://github.com/pepe/trolley"
  :dependencies ["https://github.com/joy-framework/tester"])

(declare-source
  :source @["src/router.janet"])
  :source @["src/trolley.janet"])

R src/router.janet => src/trolley.janet +0 -0
R test/router.janet => test/trolley.janet +7 -7
@@ 1,10 1,10 @@
(import tester :prefix "")
(import ../src/router :as router)
(import ../src/trolley :as trolley)


(deftest "Compile routes"
  (def compiled-routes 
    (router/compile-routes {"/" :root "/home/:id" :home}))
    (trolley/compile-routes {"/" :root "/home/:id" :home}))

  (test "are compiled" compiled-routes)



@@ 20,19 20,19 @@

(deftest "Lookup uri"
  (def compiled-routes 
    (router/compile-routes {"/" :root "/home/:id" :home}))
    (trolley/compile-routes {"/" :root "/home/:id" :home}))

  (test "lookup"
        (deep= (router/lookup compiled-routes "/home/3") 
        (deep= (trolley/lookup compiled-routes "/home/3") 
               [:home @{:id "3"}]))
  (test "lookup root"
        (deep= (router/lookup compiled-routes "/") 
        (deep= (trolley/lookup compiled-routes "/") 
               [:root @{}]))
  (test "lookup rooty"
        (empty? (router/lookup compiled-routes "/home/"))))
        (empty? (trolley/lookup compiled-routes "/home/"))))

(deftest "Router"
  (def router (router/router {"/" :root 
  (def router (trolley/router {"/" :root 
                              "/home/:id" :home}))
  (test "root"
        (deep= (router "/") [:root @{}]))