Skip to content

Commit

Permalink
Removes duplicate options (#66)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonatan Kłosko <[email protected]>
  • Loading branch information
cristineguadelupe and jonatanklosko authored Jan 11, 2024
1 parent 74dcd97 commit 49458e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/kino/maplibre.ex
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ defmodule Kino.MapLibre do
"""
@spec add_nav_controls(maplibre(), keyword()) :: :ok | %__MODULE__{}
def add_nav_controls(map, opts \\ []) do
position = Keyword.get(opts, :position, "top-right")
{position, opts} = Keyword.pop(opts, :position, "top-right")
control = %{position: position, options: normalize_opts(opts)}
update_events(map, :controls, control)
end
Expand Down Expand Up @@ -203,7 +203,7 @@ defmodule Kino.MapLibre do
"""
@spec add_locate(maplibre(), keyword()) :: :ok | %__MODULE__{}
def add_locate(map, opts \\ []) do
high_accuracy = Keyword.get(opts, :high_accuracy, false)
{high_accuracy, opts} = Keyword.pop(opts, :high_accuracy, false)
locate = %{high_accuracy: high_accuracy, options: normalize_opts(opts)}
update_events(map, :locate, locate)
end
Expand Down
8 changes: 4 additions & 4 deletions test/kino/maplibre_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ defmodule Kino.MapLibreTest do
data = connect(ml)

assert data.events.controls == [
%{options: %{"position" => "top-left", "showZoom" => false}, position: "top-left"},
%{options: %{"showZoom" => false}, position: "top-left"},
%{options: %{"showCompass" => false}, position: "top-right"}
]

assert_broadcast_event(ml, "add_nav_controls", %{
options: %{"position" => "top-left", "showZoom" => false},
options: %{"showZoom" => false},
position: "top-left"
})
end
Expand All @@ -195,7 +195,7 @@ defmodule Kino.MapLibreTest do
Kino.MapLibre.add_locate(ml, high_accuracy: true)
data = connect(ml)

assert data.events.locate == [%{high_accuracy: true, options: %{"highAccuracy" => true}}]
assert data.events.locate == [%{high_accuracy: true, options: %{}}]

assert_broadcast_event(ml, "add_locate", %{options: %{}, high_accuracy: true})
end
Expand All @@ -207,7 +207,7 @@ defmodule Kino.MapLibreTest do

assert data.events.locate == [
%{options: %{"trackUserLocation" => true}, high_accuracy: false},
%{options: %{"highAccuracy" => true}, high_accuracy: true}
%{options: %{}, high_accuracy: true}
]

assert_broadcast_event(ml, "add_locate", %{
Expand Down

0 comments on commit 49458e9

Please sign in to comment.