Skip to content

Commit

Permalink
Merge pull request #1 from patrickojeh/feature/get-zones-list
Browse files Browse the repository at this point in the history
Feature/get zones list
  • Loading branch information
patrickojeh authored May 25, 2024
2 parents 1f26763 + ad2b4bb commit b8197ff
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['10.x', '12.x', '14.x']
node: ['18.x', '20.x']
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Nigerian Geopolitical Zones Data
# Nigerian Geopolitical Zones Data ![NPM Version](https://img.shields.io/npm/v/nigerian-geopolitical-zones)


This library contains in JSON format, Nigerian states with their various geopolitical zones. Other data includes:
- Area (in Km2)
Expand All @@ -24,9 +25,12 @@ Example:
// Utils
import { getAllZones, getZoneData, getZoneByState } from 'nigerian-geopolitical-zones';

// All 36 states (incl. FCT) with their zones
// All 36 states (plus. FCT) with their zones
getAllZones();

// Names of all zones
getZonesList();

// All states that fall in a zone
getZoneData('south east');
getZoneData('south-east');
Expand Down
14 changes: 14 additions & 0 deletions src/data/zones.json
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,20 @@
"yearCreated": 1976,
"zone": "North West"
},
{
"state": "Taraba",
"areaKm2": 54473,
"capitalCity": "Jalingo",
"coordinates": {
"latitude": 8.0000,
"longitude": 10.5000
},
"motto": "Nature's Gift to the Nation",
"population": 3331885,
"populationRank": null,
"yearCreated": 1991,
"zone": "North East"
},
{
"state": "Yobe",
"areaKm2": 45502,
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as getAllZones } from './lib/getAllZones';
export { default as getZonesList } from './lib/getZonesList';
export { default as getZoneData } from './lib/getZoneData';
export { default as getZoneByState } from './lib/getZoneByState';
15 changes: 15 additions & 0 deletions src/lib/getZonesList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import zones from "../helpers/fetchZones";

/**
* Function that returns an array containing only the names of the 6 geopolitical zones in Nigeria
* @returns {Array<string>}
*/
function getZonesList(): string[] {
const list: string[] = zones.map(item => item.zone);

const uniqueList: Set<string> = new Set(list);

return Array.from(uniqueList);
}

export default getZonesList;
2 changes: 1 addition & 1 deletion test/getAllZones.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import getAllZones from '../src/lib/getAllZones';
import { getAllZones } from '../src/index';
import { ZonesInterface } from '../src/shared/interfaces';

describe('functionality to get data for all zones', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/getZoneByState.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import getZoneByState from '../src/lib/getZoneByState';
import { getZoneByState } from '../src/index';
import { ZonesInterface } from '../src/shared/interfaces';

describe('functionality to get data for a particular state', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/getZoneData.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import getZoneData from '../src/lib/getZoneData';
import { getZoneData } from '../src/index';
import { ZonesInterface } from '../src/shared/interfaces';

describe('functionality to get data for a particular zone', () => {
Expand Down
11 changes: 11 additions & 0 deletions test/getZonesList.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { getZonesList } from '../src/index';

describe('functionality to return just the names of all geopolitical zones', () => {
test('should return an array containing strings of 6 items', () => {
const zones: string[] = getZonesList();

expect(Array.isArray(zones)).toBeTruthy();
expect(zones.length == 6).toBeTruthy();
expect(typeof zones[0] === 'string').toBeTruthy();
})
})

0 comments on commit b8197ff

Please sign in to comment.