Skip to content

Commit

Permalink
Merge pull request #47 from Stassi/feature/mobile-tutorial-test
Browse files Browse the repository at this point in the history
feature/mobile-tutorial-test
  • Loading branch information
Stassi authored Oct 7, 2024
2 parents c2a1708 + c8648a0 commit 1d22621
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stassi/leaf",
"version": "0.0.46",
"version": "0.0.47",
"description": "Leaflet adapter.",
"keywords": [
"cartography",
Expand Down
59 changes: 59 additions & 0 deletions src/tutorial/mobile/mobile.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
type Source = string | null

describe('mobile tutorial', (): void => {
beforeAll(async (): Promise<void> => {
await browser
.defaultBrowserContext()
.overridePermissions('http://localhost:3001', ['geolocation'])

await page.setGeolocation({
accuracy: 10,
latitude: 51.505,
longitude: -0.09,
})

await page.goto('http://localhost:3001/tutorial/mobile/mobile')
})

describe('map', (): void => {
// eslint-disable-next-line jest/prefer-lowercase-title -- official case
describe('OpenStreetMap tiles', (): void => {
it('should render', async (): Promise<void> => {
;(
await page.$$eval(
'.leaflet-tile-loaded',
(tiles: Element[]): Source[] =>
tiles.map((tile: Element): Source => tile.getAttribute('src')),
)
).forEach((source: Source): void => {
expect(source).toMatch(/^https:\/\/tile\.openstreetmap\.org\//)
})
})
})

describe('layer', (): void => {
describe('circle', (): void => {
it('should render', async (): Promise<void> => {
expect(await page.$('path.leaflet-interactive')).toBeDefined()
})
})

describe('marker', (): void => {
it('should render', async (): Promise<void> => {
expect(await page.$('.leaflet-marker-icon')).toBeDefined()
})
})

describe('popup text', (): void => {
it('should display user location accuracy', async (): Promise<void> => {
expect(
await page.$eval(
'.leaflet-popup-content',
({ textContent }: Element): Source => textContent,
),
).toBe('You are within 10 meters from this point.')
})
})
})
})
})

0 comments on commit 1d22621

Please sign in to comment.