Skip to content

Commit 2a922f4

Browse files
committed
feat: addressing PR comments
1 parent 3149873 commit 2a922f4

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

packages/geolocation-controller/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Accept ISO 3166-2 subdivision codes (e.g. `US-NY`, `CA-ON`) from the geolocation API, not just 2-letter country codes ([#8137](https://github.com/MetaMask/core/pull/8137))
13+
1014
## [0.1.0]
1115

1216
### Added

packages/geolocation-controller/src/geolocation-api-service/geolocation-api-service.test.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('GeolocationApiService', () => {
2323
});
2424

2525
describe('GeolocationApiService:fetchGeolocation', () => {
26-
it('returns the fetched country code', async () => {
26+
it('returns the fetched location code', async () => {
2727
const { rootMessenger } = getService({
2828
options: { fetch: createMockFetch('GB') },
2929
});
@@ -264,13 +264,31 @@ describe('GeolocationApiService', () => {
264264
expect(result).toBe('US-NY');
265265
});
266266

267-
it('accepts a subdivision code with alphanumeric part', async () => {
268-
const mockFetch = createMockFetch('CA-ON');
267+
it('accepts a numeric subdivision code', async () => {
268+
const mockFetch = createMockFetch('FR-75');
269269
const { service } = getService({ options: { fetch: mockFetch } });
270270

271271
const result = await service.fetchGeolocation();
272272

273-
expect(result).toBe('CA-ON');
273+
expect(result).toBe('FR-75');
274+
});
275+
276+
it('accepts a single-character subdivision code', async () => {
277+
const mockFetch = createMockFetch('ES-M');
278+
const { service } = getService({ options: { fetch: mockFetch } });
279+
280+
const result = await service.fetchGeolocation();
281+
282+
expect(result).toBe('ES-M');
283+
});
284+
285+
it('accepts a mixed alphanumeric subdivision code', async () => {
286+
const mockFetch = createMockFetch('GB-H9');
287+
const { service } = getService({ options: { fetch: mockFetch } });
288+
289+
const result = await service.fetchGeolocation();
290+
291+
expect(result).toBe('GB-H9');
274292
});
275293

276294
it('returns UNKNOWN_LOCATION for non-ISO responses', async () => {

0 commit comments

Comments
 (0)