Skip to content

Commit

Permalink
describe vector layer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stassi committed Sep 22, 2024
1 parent 2737123 commit fa7d9f6
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions src/tutorial/quick-start/quick-start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,45 @@ describe('quick-start tutorial', () => {
})
})

describe('red circle over South Bank district, Lambeth, London', () => {
it('should display popup with text "I am a circle." when clicked', async () => {
const element: ElementHandle<SVGPathElement> | null = await page.$(
'path.leaflet-interactive[stroke="red"]',
)
if (!element) throw new Error('Element not found.')
await element.click()
describe('vector layers display popup text on click', () => {
describe('red circle over South Bank district, Lambeth, London', () => {
it('should display popup text "I am a circle."', async () => {
const element: ElementHandle<SVGPathElement> | null = await page.$(
'path.leaflet-interactive[stroke="red"]',
)
if (!element) throw new Error('Element not found.')
await element.click()

await page.waitForFunction(
() =>
document.querySelector('.leaflet-popup-content')?.textContent ===
'I am a circle.',
)
await page.waitForFunction(
() =>
document.querySelector('.leaflet-popup-content')?.textContent ===
'I am a circle.',
)

expect(
await page.$eval('.leaflet-popup-content', (el) => el.textContent),
).toBe('I am a circle.')
expect(
await page.$eval('.leaflet-popup-content', (el) => el.textContent),
).toBe('I am a circle.')
})
})
})

describe('blue polygon over London neighborhood Wapping', () => {
it('should display popup with text "I am a polygon." when clicked', async () => {
const element: ElementHandle<SVGPathElement> | null = await page.$(
'path.leaflet-interactive[stroke="#3388ff"]',
)
if (!element) throw new Error('Element not found.')
await element.click()
describe('blue polygon over London neighborhood Wapping', () => {
it('should display popup text "I am a polygon."', async () => {
const element: ElementHandle<SVGPathElement> | null = await page.$(
'path.leaflet-interactive[stroke="#3388ff"]',
)
if (!element) throw new Error('Element not found.')
await element.click()

await page.waitForFunction(
() =>
document.querySelector('.leaflet-popup-content')?.textContent ===
'I am a polygon.',
)
await page.waitForFunction(
() =>
document.querySelector('.leaflet-popup-content')?.textContent ===
'I am a polygon.',
)

expect(
await page.$eval('.leaflet-popup-content', (el) => el.textContent),
).toBe('I am a polygon.')
expect(
await page.$eval('.leaflet-popup-content', (el) => el.textContent),
).toBe('I am a polygon.')
})
})
})
})
Expand Down

0 comments on commit fa7d9f6

Please sign in to comment.