-
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 #1 from patrickojeh/feature/get-zones-list
Feature/get zones list
- Loading branch information
Showing
9 changed files
with
52 additions
and
7 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 |
---|---|---|
@@ -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'; |
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 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; |
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,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(); | ||
}) | ||
}) |