1module SplitParams.Spec where
5import Test.Spec (Spec, describe, it)
6import Test.Spec.Assertions (shouldEqual)
7import Yoga.Fetch.Om.SplitParams (splitParams)
10spec = describe "splitParams" do
11 it "splits path and query params" do
13 allParams = { id: 42, limit: 10, offset: 20 }
16 :: { path :: { id :: Int }
17 , query :: { limit :: Int, offset :: Int }
20 result.path.id `shouldEqual` 42
21 result.query.limit `shouldEqual` 10
22 result.query.offset `shouldEqual` 20
23 result.body `shouldEqual` {}
25 it "splits path and body params" do
27 allParams = { id: 42, name: "Alice", email: "alice@example.com" }
30 :: { path :: { id :: Int }
32 , body :: { name :: String, email :: String }
34 result.path.id `shouldEqual` 42
35 result.query `shouldEqual` {}
36 result.body.name `shouldEqual` "Alice"
37 result.body.email `shouldEqual` "alice@example.com"
39 it "splits all three param types" do
48 :: { path :: { id :: Int }
49 , query :: { limit :: Int }
50 , body :: { name :: String }
52 result.path.id `shouldEqual` 42
53 result.query.limit `shouldEqual` 10
54 result.body.name `shouldEqual` "Bob"
56 it "handles empty splits" do
58 allParams = { id: 42 }
61 :: { path :: { id :: Int }
65 result.path.id `shouldEqual` 42
66 result.query `shouldEqual` {}
67 result.body `shouldEqual` {}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list