以下测试导致运行时异常:
test "search yields profile" <|
\_ ->
let
-- Setup
location =
Navigation.Location "" "" "" "" "" "" "" "" "" "" ""
( model, _ ) =
Home.init location
-- Test
( newState, _ ) =
model |> Home.update (Search "Scott")
-- Verify
( onlyOne, isContentProvider1 ) =
( (newState.contentProviders |> List.length) == 1
, newState.contentProviders |> List.member contentProvider1
)
in
Expect.equal (onlyOne && isContentProvider1) True
TypeError: Cannot read property 'href' of undefined
at Object.getLocation (eval at <anonymous> (my_path\AppData\Roaming\npm\node_modules\elm-test\lib\runner.js:84:37),
<anonymous>:1392 6:17)
at Function.eval (eval at <anonymous> (my_path\AppData\Roaming\npm\node_modules\elm-test\lib\runner.js:84:37),
<anonymous>:14127:43)
at A2 (eval at <anonymous> (my_path\AppData\Roaming\npm\node_modules\elm-test\lib\runner.js:84:37),
<anonymous>:92:11)
at eval (eval at <anonymous> (my_path\AppData\Roaming\npm\node_modules\elm-test\lib\runner.js:84:37),
<anonymous>:21270:31)
at eval (eval at <anonymous> (my_path\AppData\Roaming\npm\node_modules\elm-test\lib\runner.js:84:37),
<anonymous>:22757:4)
at my_path\AppData\Roaming\npm\node_modules\elm-test\lib\runner.js:84:32
at Object.evalElmCode (my_path\AppData\Roaming\npm\node_modules\elm-test\lib\runner.js:84:76)
at my_path\AppData\Roaming\npm\node_modules\elm-test\bin\elm-test:196:14
at my_path\AppData\Roaming\npm\node_modules\elm-test\node_modules\graceful-fs\graceful-fs.js:78:16
at tryToString (fs.js:456:3)
我的预感是Navigaton.Location是例外。但是,我不知道如何解决这个问题。
源代码可以在GitHub上找到。