-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from parkerdavis1/dev
Handle geolocation error, handle timezone error, add tests
- Loading branch information
Showing
10 changed files
with
100 additions
and
35 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
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,23 @@ | ||
import { test, expect } from 'vitest'; | ||
import { find } from 'geo-tz'; | ||
|
||
test('Timezone is able to be found with some edge case GPS coordinates', () => { | ||
// threw error in RainCrow with geo-tz 8.0.1 | ||
expect(find(41.796014, -87.576506)).toStrictEqual(['America/Chicago']); | ||
// threw error in RainCrow with geo-tz 8.0.1 | ||
expect(find(24.597694, -81.583389)).toStrictEqual(['America/New_York']); | ||
// threw error in RainCrow with geo-tz 8.0.1 | ||
expect(find(24.566016, -81.673234)).toStrictEqual(['America/New_York']); | ||
// gave problems on github issue apparently | ||
expect(find(-24.244125928804735, -53.8226425697034)).toStrictEqual(['America/Sao_Paulo']); | ||
// gave problems on github issue apparently | ||
expect(find(34.05861, -118.3928)).toStrictEqual(['America/Los_Angeles']); | ||
// Edge of Reservation Land in NE AZ (Rez) | ||
expect(find(35.1578900375291, -111.24227457293293)).toStrictEqual(['America/Denver']); | ||
// Edge of Reservation Land in NE AZ (Non-rez) | ||
expect(find(35.15698602683568, -111.24796115826194)).toStrictEqual(['America/Phoenix']); | ||
// Middle of the Atlantic Ocean | ||
expect(find(43.298646833300026, -38.425597455498185)).toStrictEqual(['Etc/GMT+3']); | ||
// CA/AZ border | ||
expect(find(33.608429524254916, -114.53309086102836)).toStrictEqual(['America/Los_Angeles']); | ||
}); |
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,15 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
import { validateLatlon } from './validation'; | ||
|
||
describe('Validate Lat Lon', () => { | ||
test('validates valid lat lon', () => { | ||
expect(validateLatlon('33.33, -22.22')).toBe(true); | ||
expect(validateLatlon('33.0, -82.2')).toBe(true); | ||
}); | ||
test('Rejects invalid latlon', () => { | ||
expect(validateLatlon('-91.00, 111.11')).toBe(false); | ||
expect(validateLatlon('91.00, 111.11')).toBe(false); | ||
expect(validateLatlon('44.4, -181.0')).toBe(false); | ||
expect(validateLatlon('44.4, 181.0')).toBe(false); | ||
}); | ||
}); |
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,22 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('Error is displayed when user denies geolocation', async ({ page }) => { | ||
await page.goto('/'); | ||
await page.getByRole('button', { name: 'Pre-Submit' }).click(); | ||
await page.getByRole('button', { name: 'Locate' }).click(); | ||
await expect(page.getByText('Allow location access to use')).toBeVisible(); | ||
}); | ||
|
||
test.describe('When Geolocation is granted', () => { | ||
test.use({ | ||
geolocation: { longitude: 41.890221, latitude: 12.492348 }, | ||
permissions: ['geolocation'] | ||
}); | ||
|
||
test('Locate button works and fills out the input', async ({ page }) => { | ||
await page.goto('/'); | ||
await page.getByRole('button', { name: 'Pre-Submit' }).click(); | ||
await page.getByRole('button', { name: 'Locate' }).click(); | ||
await expect(page.getByLabel('Location (Latitude, Longitude)')).not.toBeEmpty(); | ||
}); | ||
}); |
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