github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/web/elm/tests/RoutesTests.elm (about) 1 module RoutesTests exposing (all) 2 3 import Expect 4 import Routes 5 import Test exposing (Test, describe, test) 6 import Url 7 8 9 all : Test 10 all = 11 describe "Routes" 12 [ test "parses dashboard search query respecting space" <| 13 \_ -> 14 Routes.parsePath 15 { protocol = Url.Http 16 , host = "" 17 , port_ = Nothing 18 , path = "/" 19 , query = Just "search=asdf+sd" 20 , fragment = Nothing 21 } 22 |> Expect.equal 23 (Just (Routes.Dashboard { searchType = Routes.Normal "asdf sd", dashboardView = Routes.ViewNonArchivedPipelines })) 24 , test "parses dashboard without search" <| 25 \_ -> 26 Routes.parsePath 27 { protocol = Url.Http 28 , host = "" 29 , port_ = Nothing 30 , path = "/" 31 , query = Nothing 32 , fragment = Nothing 33 } 34 |> Expect.equal 35 (Just (Routes.Dashboard { searchType = Routes.Normal "", dashboardView = Routes.ViewNonArchivedPipelines })) 36 , test "parses dashboard with 'all' view" <| 37 \_ -> 38 Routes.parsePath 39 { protocol = Url.Http 40 , host = "" 41 , port_ = Nothing 42 , path = "/" 43 , query = Just "view=all" 44 , fragment = Nothing 45 } 46 |> Expect.equal 47 (Just (Routes.Dashboard { searchType = Routes.Normal "", dashboardView = Routes.ViewAllPipelines })) 48 , test "parses dashboard with unknown view defaults to non archived only" <| 49 \_ -> 50 Routes.parsePath 51 { protocol = Url.Http 52 , host = "" 53 , port_ = Nothing 54 , path = "/" 55 , query = Just "view=blah" 56 , fragment = Nothing 57 } 58 |> Expect.equal 59 (Just (Routes.Dashboard { searchType = Routes.Normal "", dashboardView = Routes.ViewNonArchivedPipelines })) 60 , test "parses dashboard in hd view" <| 61 \_ -> 62 Routes.parsePath 63 { protocol = Url.Http 64 , host = "" 65 , port_ = Nothing 66 , path = "/hd" 67 , query = Nothing 68 , fragment = Nothing 69 } 70 |> Expect.equal 71 (Just (Routes.Dashboard { searchType = Routes.HighDensity, dashboardView = Routes.ViewNonArchivedPipelines })) 72 , test "fly success has noop parameter" <| 73 \_ -> 74 Routes.parsePath 75 { protocol = Url.Http 76 , host = "" 77 , port_ = Nothing 78 , path = "/fly_success" 79 , query = Just "fly_port=1234&noop=true" 80 , fragment = Nothing 81 } 82 |> Expect.equal 83 (Just <| Routes.FlySuccess True (Just 1234)) 84 , test "fly noop parameter defaults to False" <| 85 \_ -> 86 Routes.parsePath 87 { protocol = Url.Http 88 , host = "" 89 , port_ = Nothing 90 , path = "/fly_success" 91 , query = Just "fly_port=1234" 92 , fragment = Nothing 93 } 94 |> Expect.equal 95 (Just <| Routes.FlySuccess False (Just 1234)) 96 , test "toString serializes 'all' dashboard view" <| 97 \_ -> 98 ("http://example.com" 99 ++ Routes.toString (Routes.Dashboard { searchType = Routes.Normal "hello world", dashboardView = Routes.ViewAllPipelines }) 100 ) 101 |> Url.fromString 102 |> Maybe.andThen Routes.parsePath 103 |> Expect.equal (Just <| Routes.Dashboard { searchType = Routes.Normal "hello world", dashboardView = Routes.ViewAllPipelines }) 104 , test "toString doesn't serialize 'non_archived' dashboard view" <| 105 \_ -> 106 Routes.toString (Routes.Dashboard { searchType = Routes.Normal "", dashboardView = Routes.ViewNonArchivedPipelines }) 107 |> Expect.equal "/" 108 , test "toString respects noop parameter with a fly port" <| 109 \_ -> 110 ("http://example.com" 111 ++ Routes.toString (Routes.FlySuccess True (Just 1234)) 112 ) 113 |> Url.fromString 114 |> Maybe.andThen Routes.parsePath 115 |> Expect.equal (Just <| Routes.FlySuccess True (Just 1234)) 116 , test "toString respects noop parameter without a fly port" <| 117 \_ -> 118 ("http://example.com" 119 ++ Routes.toString (Routes.FlySuccess True Nothing) 120 ) 121 |> Url.fromString 122 |> Maybe.andThen Routes.parsePath 123 |> Expect.equal (Just <| Routes.FlySuccess True Nothing) 124 ]