|
1 | 1 | import { test, expect } from '@playwright/test'; |
2 | 2 | import { |
3 | 3 | isValidGrid, |
| 4 | + gridLocatorError, |
4 | 5 | gridToLatLon, |
5 | 6 | distanceKm, |
6 | 7 | bearingDeg, |
@@ -41,6 +42,28 @@ test.describe('isValidGrid', () => { |
41 | 42 | }); |
42 | 43 | }); |
43 | 44 |
|
| 45 | +test.describe('gridLocatorError', () => { |
| 46 | + test('treats blank/whitespace as no error (grid is optional)', () => { |
| 47 | + expect(gridLocatorError('')).toBeNull(); |
| 48 | + expect(gridLocatorError(' ')).toBeNull(); |
| 49 | + }); |
| 50 | + |
| 51 | + test('accepts 4-, 6-, and 8-character locators like isValidGrid', () => { |
| 52 | + expect(gridLocatorError('FN31')).toBeNull(); |
| 53 | + expect(gridLocatorError('FN31pr')).toBeNull(); |
| 54 | + // The regression this guards: an 8-char extended locator is valid app-wide |
| 55 | + // (isValidGrid, gridToLatLon) and must not be rejected by form/API checks. |
| 56 | + expect(gridLocatorError('FN31pr55')).toBeNull(); |
| 57 | + expect(gridLocatorError(' jn58td99 ')).toBeNull(); |
| 58 | + }); |
| 59 | + |
| 60 | + test('returns a helpful message for a malformed locator', () => { |
| 61 | + expect(gridLocatorError('nope')).toContain('Invalid grid locator'); |
| 62 | + expect(gridLocatorError('FN31p')).toContain('Invalid grid locator'); |
| 63 | + expect(gridLocatorError('FN3155')).toContain('Invalid grid locator'); |
| 64 | + }); |
| 65 | +}); |
| 66 | + |
44 | 67 | test.describe('gridToLatLon', () => { |
45 | 68 | test('returns the center of a 4-character square', () => { |
46 | 69 | // JJ00 straddles the prime meridian / equator origin of the grid; its |
|
0 commit comments