mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-26 05:13:24 +03:00
Fix test errors.
This commit is contained in:
parent
6d2ce4d542
commit
3e65d2fae1
@ -1,12 +1,15 @@
|
|||||||
module StaticHttpRequestsTests exposing (all)
|
module StaticHttpRequestsTests exposing (all)
|
||||||
|
|
||||||
import ApiRoute
|
import ApiRoute
|
||||||
|
import Bytes.Decode
|
||||||
|
import Bytes.Encode
|
||||||
import Codec
|
import Codec
|
||||||
import DataSource exposing (DataSource)
|
import DataSource exposing (DataSource)
|
||||||
import DataSource.Http
|
import DataSource.Http
|
||||||
import Dict
|
import Dict
|
||||||
import Expect
|
import Expect
|
||||||
import Html
|
import Html
|
||||||
|
import Http
|
||||||
import Json.Decode as JD exposing (Decoder)
|
import Json.Decode as JD exposing (Decoder)
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
import Pages.ContentCache as ContentCache exposing (ContentCache)
|
import Pages.ContentCache as ContentCache exposing (ContentCache)
|
||||||
@ -23,10 +26,13 @@ import Path
|
|||||||
import ProgramTest exposing (ProgramTest)
|
import ProgramTest exposing (ProgramTest)
|
||||||
import Regex
|
import Regex
|
||||||
import RenderRequest
|
import RenderRequest
|
||||||
|
import Server.Request
|
||||||
import Server.Response as Response
|
import Server.Response as Response
|
||||||
import SimulatedEffect.Cmd
|
import SimulatedEffect.Cmd
|
||||||
import SimulatedEffect.Ports
|
import SimulatedEffect.Ports
|
||||||
|
import SimulatedEffect.Sub
|
||||||
import SimulatedEffect.Task
|
import SimulatedEffect.Task
|
||||||
|
import Task
|
||||||
import Test exposing (Test, describe, test)
|
import Test exposing (Test, describe, test)
|
||||||
|
|
||||||
|
|
||||||
@ -641,10 +647,6 @@ startLowLevel :
|
|||||||
-> ProgramTest (Model Route) Msg Effect
|
-> ProgramTest (Model Route) Msg Effect
|
||||||
startLowLevel apiRoutes staticHttpCache pages =
|
startLowLevel apiRoutes staticHttpCache pages =
|
||||||
let
|
let
|
||||||
contentCache : ContentCache
|
|
||||||
contentCache =
|
|
||||||
ContentCache.init Nothing
|
|
||||||
|
|
||||||
pageToLoad : List String
|
pageToLoad : List String
|
||||||
pageToLoad =
|
pageToLoad =
|
||||||
case pages |> List.head |> Maybe.map Tuple.first of
|
case pages |> List.head |> Maybe.map Tuple.first of
|
||||||
@ -713,6 +715,13 @@ startLowLevel apiRoutes staticHttpCache pages =
|
|||||||
, onPageChange = \_ -> Continue
|
, onPageChange = \_ -> Continue
|
||||||
, apiRoutes = \_ -> apiRoutes
|
, apiRoutes = \_ -> apiRoutes
|
||||||
, pathPatterns = []
|
, pathPatterns = []
|
||||||
|
, byteDecodePageData = \_ -> Bytes.Decode.fail
|
||||||
|
, sendPageData = \_ -> Cmd.none
|
||||||
|
, encodeResponse = \_ -> Bytes.Encode.signedInt8 0
|
||||||
|
, hotReloadData = Sub.none
|
||||||
|
, decodeResponse = Bytes.Decode.fail
|
||||||
|
, byteEncodePageData = \_ -> Bytes.Encode.signedInt8 0
|
||||||
|
, fetchPageData = \_ -> Task.fail Http.NetworkError
|
||||||
}
|
}
|
||||||
|
|
||||||
encodedFlags : Encode.Value
|
encodedFlags : Encode.Value
|
||||||
@ -762,9 +771,8 @@ startLowLevel apiRoutes staticHttpCache pages =
|
|||||||
)
|
)
|
||||||
(Encode.object [])
|
(Encode.object [])
|
||||||
)
|
)
|
||||||
contentCache
|
|
||||||
config
|
config
|
||||||
, update = update site contentCache config
|
, update = update site config
|
||||||
, view = \_ -> { title = "", body = [] }
|
, view = \_ -> { title = "", body = [] }
|
||||||
}
|
}
|
||||||
|> ProgramTest.withSimulatedEffects simulateEffects
|
|> ProgramTest.withSimulatedEffects simulateEffects
|
||||||
@ -798,10 +806,6 @@ startWithRoutes :
|
|||||||
-> ProgramTest (Model Route) Msg Effect
|
-> ProgramTest (Model Route) Msg Effect
|
||||||
startWithRoutes pageToLoad staticRoutes staticHttpCache pages =
|
startWithRoutes pageToLoad staticRoutes staticHttpCache pages =
|
||||||
let
|
let
|
||||||
contentCache : ContentCache
|
|
||||||
contentCache =
|
|
||||||
ContentCache.init Nothing
|
|
||||||
|
|
||||||
config : ProgramConfig Msg () Route () () ()
|
config : ProgramConfig Msg () Route () () ()
|
||||||
config =
|
config =
|
||||||
{ toJsPort = toJsPort
|
{ toJsPort = toJsPort
|
||||||
@ -843,7 +847,8 @@ startWithRoutes pageToLoad staticRoutes staticHttpCache pages =
|
|||||||
in
|
in
|
||||||
case thing of
|
case thing of
|
||||||
Just request ->
|
Just request ->
|
||||||
request |> DataSource.map (\_ -> Response.render ())
|
request
|
||||||
|
|> DataSource.map (\_ -> Response.render ())
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
DataSource.fail <| "Couldn't find page: " ++ pageRoute ++ "\npages: " ++ Debug.toString pages
|
DataSource.fail <| "Couldn't find page: " ++ pageRoute ++ "\npages: " ++ Debug.toString pages
|
||||||
@ -870,6 +875,13 @@ startWithRoutes pageToLoad staticRoutes staticHttpCache pages =
|
|||||||
, onPageChange = \_ -> Continue
|
, onPageChange = \_ -> Continue
|
||||||
, apiRoutes = \_ -> []
|
, apiRoutes = \_ -> []
|
||||||
, pathPatterns = []
|
, pathPatterns = []
|
||||||
|
, byteDecodePageData = \_ -> Bytes.Decode.fail
|
||||||
|
, sendPageData = \_ -> Cmd.none
|
||||||
|
, encodeResponse = \_ -> Bytes.Encode.signedInt8 0
|
||||||
|
, hotReloadData = Sub.none
|
||||||
|
, decodeResponse = Bytes.Decode.fail
|
||||||
|
, byteEncodePageData = \_ -> Bytes.Encode.signedInt8 0
|
||||||
|
, fetchPageData = \_ -> Task.fail Http.NetworkError
|
||||||
}
|
}
|
||||||
|
|
||||||
encodedFlags : Encode.Value
|
encodedFlags : Encode.Value
|
||||||
@ -919,9 +931,8 @@ startWithRoutes pageToLoad staticRoutes staticHttpCache pages =
|
|||||||
)
|
)
|
||||||
(Encode.object [])
|
(Encode.object [])
|
||||||
)
|
)
|
||||||
contentCache
|
|
||||||
config
|
config
|
||||||
, update = update site contentCache config
|
, update = update site config
|
||||||
, view = \_ -> { title = "", body = [] }
|
, view = \_ -> { title = "", body = [] }
|
||||||
}
|
}
|
||||||
|> ProgramTest.withSimulatedEffects simulateEffects
|
|> ProgramTest.withSimulatedEffects simulateEffects
|
||||||
@ -1008,6 +1019,19 @@ simulateEffects effect =
|
|||||||
Effect.Continue ->
|
Effect.Continue ->
|
||||||
SimulatedEffect.Cmd.none
|
SimulatedEffect.Cmd.none
|
||||||
|
|
||||||
|
Effect.SendSinglePageNew done bytes toJsSuccessPayloadNewCombined ->
|
||||||
|
SimulatedEffect.Cmd.batch
|
||||||
|
[ toJsSuccessPayloadNewCombined
|
||||||
|
|> Codec.encoder (ToJsPayload.successCodecNew2 "" "")
|
||||||
|
|> SimulatedEffect.Ports.send "toJsPort"
|
||||||
|
, if done then
|
||||||
|
SimulatedEffect.Cmd.none
|
||||||
|
|
||||||
|
else
|
||||||
|
SimulatedEffect.Task.succeed ()
|
||||||
|
|> SimulatedEffect.Task.perform (\_ -> Continue)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
expectErrorsPort : String -> List ToJsPayload.ToJsSuccessPayloadNewCombined -> Expect.Expectation
|
expectErrorsPort : String -> List ToJsPayload.ToJsSuccessPayloadNewCombined -> Expect.Expectation
|
||||||
expectErrorsPort expectedPlainString actualPorts =
|
expectErrorsPort expectedPlainString actualPorts =
|
||||||
|
Loading…
Reference in New Issue
Block a user