Skip to content

Commit

Permalink
fix(elm-package): expose nb_no config
Browse files Browse the repository at this point in the history
fix(Config_nb_no): elm-format reformatted, fixed comment for config:

test(FormatTests): add test for Config_nb_no, elm-format adjusted

test(Configtests): add test for getConfig "nb_no"

fix(Configs) add lookup of "nb_no" name
  • Loading branch information
rluiten committed Mar 11, 2018
1 parent 708664e commit e36d4e7
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 18 deletions.
1 change: 1 addition & 0 deletions elm-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"Date.Extra.Config.Config_lt_lt",
"Date.Extra.Config.Config_el_gr",
"Date.Extra.Config.Config_sv_se",
"Date.Extra.Config.Config_nb_no",
"Date.Extra.Field"
],
"dependencies": {
Expand Down
17 changes: 11 additions & 6 deletions src/Date/Extra/Config/Config_nb_no.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Date.Extra.I18n.I_default as Default
import Date.Extra.I18n.I_nb_no as Norwegian


{-| Config for sv-se.
{-| Config for nb-no.
-}
config : Config.Config
config =
Expand All @@ -25,19 +25,24 @@ config =
, format =
{ date =
"%Y-%m-%d"
-- YYYY-MM-DD (L equivalent in moment.js)

-- YYYY-MM-DD (L equivalent in moment.js)
, longDate =
"%A %-d %B %Y"
-- dddd D MMMM YYYY

-- dddd D MMMM YYYY
, time =
"%H:%M"
-- HH:mm

-- HH:mm
, longTime =
"%H:%M:%S"
-- HH:mm:ss

-- HH:mm:ss
, dateTime =
"%Y-%m-%d %H:%M"
-- YYYY-MM-DD HH:mm

-- YYYY-MM-DD HH:mm
, firstDayOfWeek = Date.Mon
}
}
6 changes: 4 additions & 2 deletions src/Date/Extra/Config/Configs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Date.Extra.Config.Config_ro_ro as Config_ro_ro
import Date.Extra.Config.Config_ru_ru as Config_ru_ru
import Date.Extra.Config.Config_sv_se as Config_sv_se
import Date.Extra.Config.Config_tr_tr as Config_tr_tr
import Date.Extra.Config.Config_nb_no as Config_nb_no
import Dict exposing (Dict)
import Regex exposing (HowMany(All), regex, replace)
import String
Expand Down Expand Up @@ -60,6 +61,7 @@ configs =
, ( "el_gr", Config_el_gr.config )
, ( "sv_se", Config_sv_se.config )
, ( "es_es", Config_es_es.config )
, ( "nb_no", Config_nb_no.config )
]


Expand All @@ -80,5 +82,5 @@ getConfig id =
fixedId =
replace All (regex "-") (\_ -> "_") lowerId
in
Maybe.withDefault Config_en_us.config
(Dict.get fixedId configs)
Maybe.withDefault Config_en_us.config
(Dict.get fixedId configs)
10 changes: 10 additions & 0 deletions tests/Date/Extra/ConfigTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Date.Extra.Config.Config_ro_ro as Config_ro_ro
import Date.Extra.Config.Config_ru_ru as Config_ru_ru
import Date.Extra.Config.Config_sv_se as Config_sv_se
import Date.Extra.Config.Config_tr_tr as Config_tr_tr
import Date.Extra.Config.Config_nb_no as Config_nb_no
import Date.Extra.Config.Configs as Configs
import Expect
import Test exposing (..)
Expand Down Expand Up @@ -96,6 +97,10 @@ config_es_es =
Config_es_es.config


config_nb_no =
Config_nb_no.config


tests : Test
tests =
describe "Date.Config tests"
Expand Down Expand Up @@ -199,4 +204,9 @@ tests =
Expect.equal
config_es_es.format
(Configs.getConfig "es_es").format
, test "getConfig nb_no" <|
\() ->
Expect.equal
config_nb_no.format
(Configs.getConfig "nb_no").format
]
26 changes: 16 additions & 10 deletions tests/Date/Extra/FormatTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Date.Extra.Config.Config_ro_ro as Config_ro_ro
import Date.Extra.Config.Config_ru_ru as Config_ru_ru
import Date.Extra.Config.Config_sv_se as Config_sv_se
import Date.Extra.Config.Config_tr_tr as Config_tr_tr
import Date.Extra.Config.Config_nb_no as Config_nb_no
import Date.Extra.Core as Core
import Date.Extra.Format as Format
import Date.Extra.Period as DPeriod exposing (Period(Hour))
Expand Down Expand Up @@ -101,6 +102,10 @@ config_es_es =
Config_es_es.config


config_nb_no =
Config_nb_no.config


tests : Test
tests =
describe "Date.Format tests"
Expand Down Expand Up @@ -208,11 +213,11 @@ runFormatTest ( name, expected, formatStr, time ) =
-- , "format", (Format.formatOffset Config_en_us.config -600 formatStr asDate)
-- )
in
test name <|
\() ->
Expect.equal
expected
(Format.formatOffset Config_en_us.config -600 formatStr asDate)
test name <|
\() ->
Expect.equal
expected
(Format.formatOffset Config_en_us.config -600 formatStr asDate)


formatTestCases =
Expand Down Expand Up @@ -256,11 +261,11 @@ runConfigLanguageTest ( name, expected, config, formatStr, time ) =
asDate =
Core.fromTime time
in
test name <|
\() ->
Expect.equal
expected
(Format.formatOffset config -600 formatStr asDate)
test name <|
\() ->
Expect.equal
expected
(Format.formatOffset config -600 formatStr asDate)


{-| These tests are testing a few language field values and the day idiom function.
Expand Down Expand Up @@ -329,6 +334,7 @@ formatConfigTestCases =
, ( "Config_en_au iso day of week", "7", config_en_au, "%u", aTestTime10 )
, ( "Config_es_es day idiom", "05.08.2014", config_es_es, config_es_es.format.date, aTestTime5 )
, ( "Config_es_es format idiom", "Martes (5) 05 Agosto 2014", config_es_es, dayDayIdiomMonth, aTestTime5 )
, ( "Config_nb_no format date", "2014-08-05", config_nb_no, config_nb_no.format.date, aTestTime5 )
]


Expand Down

0 comments on commit e36d4e7

Please sign in to comment.