github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/web/elm/tests/DurationTests.elm (about)

     1  module DurationTests exposing (all, start)
     2  
     3  import Duration exposing (Duration)
     4  import Expect exposing (..)
     5  import Test exposing (..)
     6  import Time
     7  
     8  
     9  start : Int
    10  start =
    11      10 * 1000
    12  
    13  
    14  second : Int
    15  second =
    16      1 * 1000
    17  
    18  
    19  minute : Int
    20  minute =
    21      60 * 1000
    22  
    23  
    24  hour : Int
    25  hour =
    26      60 * 60 * 1000
    27  
    28  
    29  all : Test
    30  all =
    31      describe "Duration"
    32          [ describe "formatting"
    33              [ test "seconds difference" <|
    34                  \_ ->
    35                      Expect.equal
    36                          "1s"
    37                          (Duration.format <| Duration.between (Time.millisToPosix start) (Time.millisToPosix (start + second)))
    38              , test "minutes difference" <|
    39                  \_ ->
    40                      Expect.equal
    41                          "1m 2s"
    42                          (Duration.format <| Duration.between (Time.millisToPosix start) (Time.millisToPosix (start + minute + (2 * second))))
    43              , test "hours difference" <|
    44                  \_ ->
    45                      Expect.equal
    46                          "1h 2m"
    47                          (Duration.format <| Duration.between (Time.millisToPosix start) (Time.millisToPosix (start + hour + (2 * minute) + (3 * second))))
    48              , test "days difference" <|
    49                  \_ ->
    50                      Expect.equal
    51                          "1d 2h"
    52                          (Duration.format <| Duration.between (Time.millisToPosix start) (Time.millisToPosix (start + (26 * hour) + (3 * minute) + (4 * second))))
    53              ]
    54          ]