Skip to content

Commit

Permalink
test(fix): address failed tests from new elm-test.
Browse files Browse the repository at this point in the history
Failures were about unique names and empty test lists.
Strip down Tests.elm to just ech current time zone offsets.
  • Loading branch information
rluiten committed Jun 22, 2017
1 parent c528d0f commit 94f3c9c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 38 deletions.
45 changes: 43 additions & 2 deletions tests/Date/Extra/FieldTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tests =
]


runFieldCase ( dateStr, field, expectedDate ) =
runFieldCase ( dateStr, field, expectedDate, name ) =
let
date =
TestUtils.fudgeDate dateStr
Expand All @@ -37,6 +37,8 @@ runFieldCase ( dateStr, field, expectedDate ) =
in
test
("field "
++ name
++ ""
++ (toString field)
++ " on "
++ dateStr
Expand All @@ -48,84 +50,103 @@ runFieldCase ( dateStr, field, expectedDate ) =
\() -> Expect.equal (expectedDate) (dateOutStr)


fieldCases : List ( String, Field, Maybe String, String )
fieldCases =
[ ( "2016/06/05 04:03:02.111"
, Millisecond 1
, Just "2016-06-05T04:03:02.001"
, "1"
)
, ( "2016/06/05 04:03:02.111"
, Second 3
, Just "2016-06-05T04:03:03.111"
, "2"
)
, ( "2016/06/05 04:03:02.111"
, Millisecond 1000
, Nothing
, "3"
)
, ( "2016/06/05 04:03:02.111"
, Millisecond -1
, Nothing
, "4"
)
, ( "2016/06/05 04:03:02.111"
, Second 60
, Nothing
, "5"
)
, ( "2016/06/05 04:03:02.111"
, Second -1
, Nothing
, "6"
)
, ( "2016/06/05 04:03:02.111"
, Minute 60
, Nothing
, "7"
)
, ( "2016/06/05 04:03:02.111"
, Minute -1
, Nothing
, "8"
)
, ( "2016/06/05 04:03:02.111"
, Hour 24
, Nothing
, "9"
)
, ( "2016/06/05 04:03:02.111"
, Hour -1
, Nothing
, "10"
)
, ( "2016/06/05 04:03:02.111"
, DayOfMonth 0
, Nothing
, "11"
)
, ( "2016/06/05 04:03:02.111"
, DayOfMonth 31
, Nothing
, "12"
)
, ( "2016/06/05 04:03:02.111"
, Year -1
, Nothing
, "13"
)
, ( "2016/06/05 04:03:02.111"
, DayOfMonth 31
, Nothing
, "14"
)
, ( "2016/06/05 04:03:02.111"
-- 2016/06/05 is Sunday
, DayOfWeek ( Date.Mon, Date.Mon )
, Just "2016-05-30T04:03:02.111"
, "15"
)
, ( "2016/06/05 04:03:02.111"
, DayOfWeek ( Date.Mon, Date.Sun )
, Just "2016-06-06T04:03:02.111"
, "4"
)
, ( "2016/06/05 04:03:02.111"
, DayOfWeek ( Date.Thu, Date.Thu )
, Just "2016-06-02T04:03:02.111"
, "4"
)
, ( "2016/06/05 04:03:02.111"
, DayOfWeek ( Date.Sat, Date.Sun )
, Just "2016-06-11T04:03:02.111"
, "4"
)
]


runFieldClampCase ( dateStr, field, expectedDate ) =
runFieldClampCase ( dateStr, field, expectedDate, name ) =
let
date =
TestUtils.fudgeDate dateStr
Expand All @@ -141,6 +162,8 @@ runFieldClampCase ( dateStr, field, expectedDate ) =
in
test
("field "
++ name
++ " "
++ (toString field)
++ " on "
++ dateStr
Expand All @@ -158,74 +181,92 @@ fieldClampCases =
[ ( "2016/06/05 04:03:02.111"
, Millisecond 1
, "2016-06-05T04:03:02.001"
, "1"
)
, ( "2016/06/05 04:03:02.111"
, Second 3
, "2016-06-05T04:03:03.111"
, "2"
)
, ( "2016/06/05 04:03:02.111"
, Millisecond 1000
, "2016-06-05T04:03:02.999"
, "3"
)
, ( "2016/06/05 04:03:02.111"
, Millisecond -1
, "2016-06-05T04:03:02.000"
, "4"
)
, ( "2016/06/05 04:03:02.111"
, Second 60
, "2016-06-05T04:03:59.111"
, "5"
)
, ( "2016/06/05 04:03:02.111"
, Second -1
, "2016-06-05T04:03:00.111"
, "6"
)
, ( "2016/06/05 04:03:02.111"
, Minute 60
, "2016-06-05T04:59:02.111"
, "7"
)
, ( "2016/06/05 04:03:02.111"
, Minute -1
, "2016-06-05T04:00:02.111"
, "8"
)
, ( "2016/06/05 04:03:02.111"
, Hour 24
, "2016-06-05T23:03:02.111"
, "9"
)
, ( "2016/06/05 04:03:02.111"
, Hour -1
, "2016-06-05T00:03:02.111"
, "10"
)
, ( "2016/06/05 04:03:02.111"
, DayOfMonth 0
, "2016-06-01T04:03:02.111"
, "11"
)
, ( "2016/06/05 04:03:02.111"
, DayOfMonth 31
, "2016-06-30T04:03:02.111"
, "12"
)
, ( "2016/06/05 04:03:02.111"
, Year -1
, "0000-06-05T04:03:02.111"
, "13"
)
, ( "2016/06/05 04:03:02.111"
, DayOfMonth 31
, "2016-06-30T04:03:02.111"
, "14"
)
, ( "2016/06/05 04:03:02.111"
-- 2016/06/05 is Sunday
, DayOfWeek ( Date.Mon, Date.Mon )
, "2016-05-30T04:03:02.111"
, "15"
)
, ( "2016/06/05 04:03:02.111"
, DayOfWeek ( Date.Mon, Date.Sun )
, "2016-06-06T04:03:02.111"
, "16"
)
, ( "2016/06/05 04:03:02.111"
, DayOfWeek ( Date.Thu, Date.Thu )
, "2016-06-02T04:03:02.111"
, "17"
)
, ( "2016/06/05 04:03:02.111"
, DayOfWeek ( Date.Sat, Date.Sun )
, "2016-06-11T04:03:02.111"
, "17"
)
]
7 changes: 4 additions & 3 deletions tests/Date/Extra/FormatTests.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Date.Extra.FormatTests exposing (..)

{- Test date format. -}
{- Test date format.
-}

import Date exposing (Date)
import Test exposing (..)
Expand Down Expand Up @@ -209,7 +210,7 @@ formatTestCases =
-- Tue Aug 12 2014 04:53:51 GMT-0400 (Eastern Daylight Time)
, ( "with milliseconds 2", "2014-08-12T18:53:51.116", "%Y-%m-%dT%H:%M:%S.%L", aTestTime )
, ( "small year", "0448-09-09T22:39:28.884", "%Y-%m-%dT%H:%M:%S.%L", aTestTime3 )
, ( "Config_en_us date", "8/5/2014", config_en_us.format.date, aTestTime5 )
, ( "Config_en_us date aTestTime5", "8/5/2014", config_en_us.format.date, aTestTime5 )
, ( "Config_en_us longDate", "Tuesday, August 05, 2014", config_en_us.format.longDate, aTestTime5 )
, ( "Config_en_us time", "5:53 AM", config_en_us.format.time, aTestTime5 )
, ( "Config_en_us longTime", "5:53:51 AM", config_en_us.format.longTime, aTestTime5 )
Expand All @@ -221,7 +222,7 @@ formatTestCases =
, ( "Config_en_au time", "5:53 AM", config_en_au.format.time, aTestTime5 )
, ( "Config_en_au longTime", "5:53:51 AM", config_en_au.format.longTime, aTestTime5 )
, ( "Config_en_au dateTime", "5/08/2014 5:53 AM", config_en_au.format.dateTime, aTestTime5 )
, ( "Config_en_us date", "8/12/2014", config_en_us.format.date, aTestTime )
, ( "Config_en_us date aTestTime", "8/12/2014", config_en_us.format.date, aTestTime )
-- year rendered negative ? boggle :) disabled for not supporting at moment
--, ("small year", "0448-09-09T22:39:28.885", "%Y-%m-%dT%H:%M:%S.%L", aTestTime4)
, ( "Check day 12 ordinal date format with out padding", "[12][12th]", "[%-d][%-@d]", aTestTime )
Expand Down
8 changes: 7 additions & 1 deletion tests/TestUtils.elm
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,13 @@ describeOffsetTests description year candidateTests =
if (getZoneOffsets year) == offsets then
Just (test ())
else
Nothing
Just dummyPassingTest
in
describe description <|
List.filterMap currentOffsetFilter candidateTests


dummyPassingTest : Test
dummyPassingTest =
test "Dummy passing test" <|
\_ -> Expect.true "Dummy passing test" True
33 changes: 1 addition & 32 deletions tests/Tests.elm
Original file line number Diff line number Diff line change
@@ -1,38 +1,7 @@
module Tests exposing (..)

import Test exposing (..)
import Date.Extra.CreateTests as CreateTests
import Date.Extra.UtilsTests as UtilsTests
import Date.Extra.CoreTests as CoreTests
import Date.Extra.PeriodTests as PeriodTests
import Date.Extra.DurationTests as DurationTests
import Date.Extra.TimeUnitTests as TimeUnitTests
import Date.Extra.FormatTests as FormatTests
import Date.Extra.CompareTests as CompareTests
import Date.Extra.FieldTests as FieldTests
import Date.Extra.ConfigTests as ConfigTests
import Date.Extra.ConvertingTests as ConvertingTests
import TestUtils exposing (getZoneOffsets)


_ =
Debug.log "Tests Current Zone Offsets"
(getZoneOffsets 2016)


all : Test
all =
(describe "Date Extra Tests"
[ CreateTests.tests
, UtilsTests.tests
, CoreTests.tests
, PeriodTests.tests
, DurationTests.tests
, TimeUnitTests.tests
, FormatTests.tests
, CompareTests.tests
, FieldTests.tests
, ConfigTests.tests
, ConvertingTests.tests
]
)
(getZoneOffsets 2016)

0 comments on commit 94f3c9c

Please sign in to comment.