forked from lau/tzdata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_data_map_test.exs
39 lines (34 loc) · 1.5 KB
/
basic_data_map_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
defmodule BasicDataMapTest do
use ExUnit.Case, async: true
alias Tzdata.BasicDataMap
test "Existing rule" do
{:ok, map} = BasicDataMap.from_files_in_dir("test/tzdata_fixtures/source_data")
result = map[:rules]["Uruguay"]
assert hd(result)[:name] == "Uruguay"
end
test "Existing zone" do
{:ok, map} = BasicDataMap.from_files_in_dir("test/tzdata_fixtures/source_data")
result = map[:zones]["Europe/Copenhagen"]
assert result[:name] == "Europe/Copenhagen"
end
test "trying to get non existing zone should result in error" do
{:ok, map} = BasicDataMap.from_files_in_dir("test/tzdata_fixtures/source_data")
result = map[:zones]["Foo/Bar"]
assert result == nil
end
test "trying to get non existing rules should result in error" do
{:ok, map} = BasicDataMap.from_files_in_dir("test/tzdata_fixtures/source_data")
result = map[:rules]["Narnia"]
assert result == nil
end
test "Should provide list of zone names and link names" do
{:ok, map} = BasicDataMap.from_files_in_dir("test/tzdata_fixtures/source_data")
# London is cononical zone. Jersey is a link
assert map[:zone_list] |> Enum.member?("Europe/London")
assert map[:zone_list] |> Enum.member?("Europe/Jersey") != true
assert map[:link_list] |> Enum.member?("Europe/London") != true
assert map[:link_list] |> Enum.member?("Europe/Jersey")
assert map[:zone_and_link_list] |> Enum.member?("Europe/London")
assert map[:zone_and_link_list] |> Enum.member?("Europe/Jersey")
end
end