Skip to content

Commit

Permalink
feat(geoUtils): rename to getCityAdministrativeDivision
Browse files Browse the repository at this point in the history
  • Loading branch information
arisGio committed Aug 31, 2024
1 parent a8ad53f commit 9e7b92e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/geoUtils.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- [**getMunicipalities()**](#getMunicipalities)
- [**getCities()**](#getCities)
- [**getCityById()**](#getCityById)
- [**getCityRelations()**](#getCityRelations)
- [**getCityAdministrativeDivision()**](#getCityAdministrativeDivision)
- [**getGeographicRegions()**](#getGeographicRegions)
- [**getGeographicRegionById()**](#getGeographicRegionById)
- [**getPrefectures()**](#getPrefectures)
Expand Down Expand Up @@ -313,7 +313,7 @@ The functions dealing with postal codes is listed below:

---

### getCityRelations()<a id='getCityRelations'></a>
### getCityAdministrativeDivision()<a id='getCityAdministrativeDivision'></a>

**Description**: Retrieves city relations by its ID and entity.

Expand Down
22 changes: 11 additions & 11 deletions src/__tests__/geoUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
getAllPostalCodes,
getAllTaxOffices,
getCities,
getCityAdministrativeDivision,
getCityById,
getCityRelations,
getGeographicRegionById,
getGeographicRegions,
getMunicipalities,
Expand Down Expand Up @@ -518,7 +518,7 @@ describe("getCityById", () => {
});
});

describe("getCityRelations", () => {
describe("getCityAdministrativeDivision", () => {
const locale = "el";

it("should return a Region when entity is region", () => {
Expand All @@ -530,7 +530,7 @@ describe("getCityRelations", () => {
seat: "Αθήνα",
};

expect(getCityRelations(options)).toEqual(expectedData);
expect(getCityAdministrativeDivision(options)).toEqual(expectedData);
});

it('should return a Unit when entity is "unit"', () => {
Expand All @@ -543,7 +543,7 @@ describe("getCityRelations", () => {
carPlatesPattern: [],
};

expect(getCityRelations(options)).toEqual(expectedData);
expect(getCityAdministrativeDivision(options)).toEqual(expectedData);
});

it.skip('should return a RegionWithoutUnits when entity is "municipality"', () => {
Expand All @@ -559,7 +559,7 @@ describe("getCityRelations", () => {
},
};

expect(getCityRelations(options)).toEqual(expectedData);
expect(getCityAdministrativeDivision(options)).toEqual(expectedData);
});

it('should return a Prefecture when entity is "prefecture"', () => {
Expand All @@ -575,14 +575,14 @@ describe("getCityRelations", () => {
},
};

expect(getCityRelations(options)).toEqual(expectedData);
expect(getCityAdministrativeDivision(options)).toEqual(expectedData);
});

it("should return undefined when entity is not recognized", () => {
const options = { id: 1, locale, entity: "asdf" };
const expectedData = undefined;

expect(getCityRelations(options as FindByCityRelationsOptions)).toEqual(expectedData);
expect(getCityAdministrativeDivision(options as FindByCityRelationsOptions)).toEqual(expectedData);
});

it("should return undefined when id has no relations", () => {
Expand All @@ -593,10 +593,10 @@ describe("getCityRelations", () => {
const options4: FindByCityRelationsOptions = { id: 50, locale, entity: "prefecture" };
const expectedData = undefined;

expect(getCityRelations(options1)).toEqual(expectedData);
expect(getCityRelations(options2)).toEqual(expectedData);
expect(getCityRelations(options3)).toEqual(expectedData);
expect(getCityRelations(options4)).toEqual(expectedData);
expect(getCityAdministrativeDivision(options1)).toEqual(expectedData);
expect(getCityAdministrativeDivision(options2)).toEqual(expectedData);
expect(getCityAdministrativeDivision(options3)).toEqual(expectedData);
expect(getCityAdministrativeDivision(options4)).toEqual(expectedData);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/geoUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ type CityRelations = Region | Unit | Municipality | Prefecture | undefined;
* @param {("region"|"unit"|"municipality"|"prefecture")} options.entity - The type of related entity to retrieve.
* @returns {Region|Unit|RegionWithoutUnits|Prefecture|undefined} - The related entity based on the specified type, or `undefined` if not found.
*/
export function getCityRelations(options: FindByCityRelationsOptions): CityRelations {
export function getCityAdministrativeDivision(options: FindByCityRelationsOptions): CityRelations {
const { id, locale = "el", entity } = options;
const city = getCityById({ id, locale });

Expand Down

0 comments on commit 9e7b92e

Please sign in to comment.