Skip to content

Commit

Permalink
Renaming controls (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristineguadelupe authored Jan 12, 2024
1 parent 89d081f commit fb5ee51
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
20 changes: 10 additions & 10 deletions lib/kino/maplibre.ex
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ defmodule Kino.MapLibre do
## Examples
Kino.MapLibre.add_locate(map)
Kino.MapLibre.add_locate(map, high_accuracy: true, track_user_location: true)
Kino.MapLibre.add_locate_control(map)
Kino.MapLibre.add_locate_control(map, high_accuracy: true, track_user_location: true)
"""
@spec add_locate(maplibre(), keyword()) :: :ok | %__MODULE__{}
def add_locate(map, opts \\ []) do
@spec add_locate_control(maplibre(), keyword()) :: :ok | %__MODULE__{}
def add_locate_control(map, opts \\ []) do
{high_accuracy, opts} = Keyword.pop(opts, :high_accuracy, false)
locate = %{high_accuracy: high_accuracy, options: normalize_opts(opts)}
update_events(map, :locate, locate)
Expand All @@ -213,10 +213,10 @@ defmodule Kino.MapLibre do
## Examples
Kino.MapLibre.add_terrain(map)
Kino.MapLibre.add_terrain_control(map)
"""
@spec add_terrain(maplibre()) :: :ok | %__MODULE__{}
def add_terrain(map) do
@spec add_terrain_control(maplibre()) :: :ok | %__MODULE__{}
def add_terrain_control(map) do
update_events(map, :terrain, %{})
end

Expand All @@ -225,10 +225,10 @@ defmodule Kino.MapLibre do
## Examples
Kino.MapLibre.add_geocode(map)
Kino.MapLibre.add_geocode_control(map)
"""
@spec add_geocode(maplibre()) :: :ok | %__MODULE__{}
def add_geocode(map) do
@spec add_geocode_control(maplibre()) :: :ok | %__MODULE__{}
def add_geocode_control(map) do
update_events(map, :geocode, %{})
end

Expand Down
32 changes: 17 additions & 15 deletions test/kino/maplibre_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ defmodule Kino.MapLibreTest do
end
end

describe "add_locate/2" do
describe "add_locate_control/2" do
test "adds a geolocate control to a static map" do
ml = Ml.new() |> Kino.MapLibre.add_locate()
ml = Ml.new() |> Kino.MapLibre.add_locate_control()
assert ml.events.locate == [%{options: %{}, high_accuracy: false}]
end

test "adds a geolocate control to a dynamic map" do
ml = Ml.new() |> Kino.MapLibre.new()
Kino.MapLibre.add_locate(ml, high_accuracy: true)
Kino.MapLibre.add_locate_control(ml, high_accuracy: true)
data = connect(ml)

assert data.events.locate == [%{high_accuracy: true, options: %{}}]
Expand All @@ -201,8 +201,10 @@ defmodule Kino.MapLibreTest do
end

test "adds a geolocate control to a converted map" do
ml = Ml.new() |> Kino.MapLibre.add_locate(high_accuracy: true) |> Kino.MapLibre.new()
Kino.MapLibre.add_locate(ml, track_user_location: true)
ml =
Ml.new() |> Kino.MapLibre.add_locate_control(high_accuracy: true) |> Kino.MapLibre.new()

Kino.MapLibre.add_locate_control(ml, track_user_location: true)
data = connect(ml)

assert data.events.locate == [
Expand All @@ -217,15 +219,15 @@ defmodule Kino.MapLibreTest do
end
end

describe "add_terrain/1" do
describe "add_terrain_control/1" do
test "adds a terrain control to a static map" do
ml = Ml.new() |> Kino.MapLibre.add_terrain()
ml = Ml.new() |> Kino.MapLibre.add_terrain_control()
assert ml.events.terrain == [%{}]
end

test "adds a terrain control to a dynamic map" do
ml = Ml.new() |> Kino.MapLibre.new()
Kino.MapLibre.add_terrain(ml)
Kino.MapLibre.add_terrain_control(ml)
data = connect(ml)

assert data.events.terrain == [%{}]
Expand All @@ -234,8 +236,8 @@ defmodule Kino.MapLibreTest do
end

test "adds a terrain control to a converted map" do
ml = Ml.new() |> Kino.MapLibre.add_terrain() |> Kino.MapLibre.new()
Kino.MapLibre.add_terrain(ml)
ml = Ml.new() |> Kino.MapLibre.add_terrain_control() |> Kino.MapLibre.new()
Kino.MapLibre.add_terrain_control(ml)
data = connect(ml)

assert data.events.terrain == [%{}, %{}]
Expand All @@ -244,15 +246,15 @@ defmodule Kino.MapLibreTest do
end
end

describe "add_geocode/1" do
describe "add_geocode_control/1" do
test "adds a geocode control to a static map" do
ml = Ml.new() |> Kino.MapLibre.add_geocode()
ml = Ml.new() |> Kino.MapLibre.add_geocode_control()
assert ml.events.geocode == [%{}]
end

test "adds a geocode control to a dynamic map" do
ml = Ml.new() |> Kino.MapLibre.new()
Kino.MapLibre.add_geocode(ml)
Kino.MapLibre.add_geocode_control(ml)
data = connect(ml)

assert data.events.geocode == [%{}]
Expand All @@ -261,8 +263,8 @@ defmodule Kino.MapLibreTest do
end

test "adds a geocode control to a converted map" do
ml = Ml.new() |> Kino.MapLibre.add_geocode() |> Kino.MapLibre.new()
Kino.MapLibre.add_geocode(ml)
ml = Ml.new() |> Kino.MapLibre.add_geocode_control() |> Kino.MapLibre.new()
Kino.MapLibre.add_geocode_control(ml)
data = connect(ml)

assert data.events.geocode == [%{}, %{}]
Expand Down

0 comments on commit fb5ee51

Please sign in to comment.