-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- #61
- Loading branch information
Showing
7 changed files
with
94 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { RouteObject } from "react-router-dom" | ||
|
||
const samplesModules = import.meta.glob("./samples/!(use)*.tsx", { | ||
eager: true, | ||
}) | ||
|
||
export const samples = Object.keys(samplesModules) | ||
.map((path) => { | ||
const { default: Component } = samplesModules[path] as { | ||
default: React.FC | ||
} | ||
|
||
const route: RouteObject = { | ||
path: path.substring("./samples/".length, path.length - ".tsx".length), | ||
element: <Component />, | ||
} | ||
return route | ||
}) | ||
.filter((route) => !route.path!.endsWith(".style")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Map } from "react-kakao-maps-sdk" | ||
import useKakaoLoader from "./useKakaoLoader" | ||
import { useState } from "react" | ||
|
||
export default function AddMapDragendEvent() { | ||
useKakaoLoader() | ||
const [result, setResult] = useState("") | ||
|
||
return ( | ||
<> | ||
<Map // 지도를 표시할 Container | ||
id="map" | ||
center={{ | ||
// 지도의 중심좌표 | ||
lat: 33.450701, | ||
lng: 126.570667, | ||
}} | ||
style={{ | ||
width: "100%", | ||
height: "350px", | ||
}} | ||
level={3} // 지도의 확대 레벨 | ||
onDragEnd={(map) => { | ||
const latlng = map.getCenter() | ||
setResult( | ||
`변경된 지도 중심좌표는 ${latlng.getLat()} 이고, 경도는 ${latlng.getLng()} 입니다`, | ||
) | ||
}} | ||
/> | ||
<p> | ||
<em>지도를 움직여 주세요!</em> | ||
</p> | ||
<p id="result">{result}</p> | ||
</> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/react-kakao-maps-sdk/__test__/addMapDragendEvent.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { test, expect } from "@playwright/test" | ||
import { getTestUrl, waitNetworkIdleWithTimeout } from "./util" | ||
|
||
test("ScreenShot 렌더링 결과 비교", async ({ page }, testInfo) => { | ||
const url = getTestUrl( | ||
"addMapDragendEvent", | ||
testInfo.config.updateSnapshots === "all", | ||
) | ||
await page.goto(url, { waitUntil: "networkidle" }) | ||
await waitNetworkIdleWithTimeout(page) | ||
await expect(page).toHaveScreenshot() | ||
|
||
const drag = async () => { | ||
const mapBoundingBox = await page.locator("#map").boundingBox() | ||
await page.mouse.move(mapBoundingBox!.x, mapBoundingBox!.y) | ||
await page.mouse.down() | ||
await page.mouse.move( | ||
mapBoundingBox!.x + mapBoundingBox!.width / 2, | ||
mapBoundingBox!.y + mapBoundingBox!.height / 2, | ||
) | ||
await page.mouse.up() | ||
await waitNetworkIdleWithTimeout(page) | ||
} | ||
|
||
await drag() | ||
await expect(page.locator("#result")).toHaveText( | ||
"변경된 지도 중심좌표는 33.452254813152855 이고, 경도는 126.5638559967347 입니다", | ||
) | ||
|
||
await drag() | ||
await expect(page.locator("#result")).toHaveText( | ||
"변경된 지도 중심좌표는 33.453808489118444 이고, 경도는 126.55705054272451 입니다", | ||
) | ||
}) |