Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swistak35 committed Mar 1, 2024
1 parent 8db76c3 commit cf8a0ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
13 changes: 8 additions & 5 deletions ruby_event_store-browser/elm/tests/DecodersTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Api exposing (eventDecoder, eventsDecoder)
import Expect
import Json.Decode
import Main exposing (..)
import Pagination
import Test exposing (..)
import Time

Expand All @@ -19,8 +20,8 @@ suite =
"""
{
"links": {
"last": "/streams/all/head/forward/20",
"next": "/streams/all/004ada1e-2f01-4ed0-9c16-63dbc82269d2/backward/20"
"last": "http://localhost:9393/api/streams/all/relationships/events?page%5Bposition%5D=head&page%5Bdirection%5D=forward&page%5Bcount%5D=20",
"next": "http://localhost:9393/api/streams/all/relationships/events?page%5Bposition%5D=664ada1e-2f01-4ed0-9c16-63dbc82269d2&page%5Bdirection%5D=backward&page%5Bcount%5D=20"
},
"data": [
{
Expand All @@ -45,7 +46,7 @@ suite =
"""

output =
Json.Decode.decodeString eventsDecoder input
Json.Decode.decodeString (eventsDecoder Pagination.empty) input
in
Expect.equal output
(Ok
Expand All @@ -62,11 +63,13 @@ suite =
, streams = Nothing
}
]
, pagination =
Pagination.empty
, links =
{ next = Just "/streams/all/004ada1e-2f01-4ed0-9c16-63dbc82269d2/backward/20"
{ next = Just { specification = (Pagination.Specification (Just "664ada1e-2f01-4ed0-9c16-63dbc82269d2") (Just "backward") (Just "20")) }
, prev = Nothing
, first = Nothing
, last = Just "/streams/all/head/forward/20"
, last = Just { specification = (Pagination.Specification (Just "head") (Just "forward") (Just "20")) }
}
}
)
Expand Down
25 changes: 13 additions & 12 deletions ruby_event_store-browser/elm/tests/RouteTest.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module RouteTest exposing (suite)

import Expect
import Pagination
import Route exposing (Route(..), buildUrl, decodeLocation, eventUrl, streamUrl)
import Test exposing (..)
import Url
Expand Down Expand Up @@ -37,39 +38,39 @@ suite =
withUrl "https://example.org"
(\baseUrl ->
Expect.equal
(buildUrl baseUrl [ "something" ])
(buildUrl baseUrl [ "something" ] [])
"/something"
)
, test "buildUrl generates proper url when subdirectory absent, but with slash" <|
\_ ->
withUrl "https://example.org/"
(\baseUrl ->
Expect.equal
(buildUrl baseUrl [ "something" ])
(buildUrl baseUrl [ "something" ] [])
"/something"
)
, test "buildUrl generates proper url with subdirectory" <|
\_ ->
withUrl "https://example.org/res"
(\baseUrl ->
Expect.equal
(buildUrl baseUrl [ "something" ])
(buildUrl baseUrl [ "something" ] [])
"/res/something"
)
, test "buildUrl generates proper url with subdirectory and slash" <|
\_ ->
withUrl "https://example.org/res/"
(\baseUrl ->
Expect.equal
(buildUrl baseUrl [ "something" ])
(buildUrl baseUrl [ "something" ] [])
"/res/something"
)
, test "buildUrl generates proper url with double subdirectory" <|
\_ ->
withUrl "https://example.org/res/foo"
(\baseUrl ->
Expect.equal
(buildUrl baseUrl [ "something" ])
(buildUrl baseUrl [ "something" ] [])
"/res/foo/something"
)
, test "decodeLocation correctly stream url" <|
Expand All @@ -80,7 +81,7 @@ suite =
(\parsedUrl ->
Expect.equal
(decodeLocation baseUrl parsedUrl)
(Just (BrowseEvents "foo"))
(Just (BrowseEvents "foo" Pagination.empty))
)
)
, test "decodeLocation correctly stream url with slash" <|
Expand All @@ -91,7 +92,7 @@ suite =
(\parsedUrl ->
Expect.equal
(decodeLocation baseUrl parsedUrl)
(Just (BrowseEvents "foo"))
(Just (BrowseEvents "foo" Pagination.empty))
)
)
, test "decodeLocation correctly stream url with subdirectory" <|
Expand All @@ -102,7 +103,7 @@ suite =
(\parsedUrl ->
Expect.equal
(decodeLocation baseUrl parsedUrl)
(Just (BrowseEvents "foo"))
(Just (BrowseEvents "foo" Pagination.empty))
)
)
, test "decodeLocation correctly stream url with subdirectory and slash" <|
Expand All @@ -113,7 +114,7 @@ suite =
(\parsedUrl ->
Expect.equal
(decodeLocation baseUrl parsedUrl)
(Just (BrowseEvents "foo"))
(Just (BrowseEvents "foo" Pagination.empty))
)
)
, test "decodeLocation correctly stream url with double subdirectory" <|
Expand All @@ -124,7 +125,7 @@ suite =
(\parsedUrl ->
Expect.equal
(decodeLocation baseUrl parsedUrl)
(Just (BrowseEvents "foo"))
(Just (BrowseEvents "foo" Pagination.empty))
)
)
, test "decodeLocation correctly top url" <|
Expand All @@ -135,7 +136,7 @@ suite =
(\parsedUrl ->
Expect.equal
(decodeLocation baseUrl parsedUrl)
(Just (BrowseEvents "all"))
(Just (BrowseEvents "all" Pagination.empty))
)
)
, test "decodeLocation correctly top url with slash" <|
Expand All @@ -146,7 +147,7 @@ suite =
(\parsedUrl ->
Expect.equal
(decodeLocation baseUrl parsedUrl)
(Just (BrowseEvents "all"))
(Just (BrowseEvents "all" Pagination.empty))
)
)
, test "decodeLocation correctly event url" <|
Expand Down

0 comments on commit cf8a0ab

Please sign in to comment.