Skip to content

Commit

Permalink
refractored import name to iso3166Lookup in readme and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
omkartapale committed Jun 23, 2022
1 parent aa487c6 commit 79d237b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ npm install iso3166-lookup
## Usage
**Using ISO 3166-1:2020 Codes lookup package into your code** ```(import / require)```
```javascript
import countries from "iso3166-lookup";
import iso3166Lookup from "iso3166-lookup";
```
OR
```javascript
const countries = require('iso3166-lookup');
const iso3166Lookup = require('iso3166-lookup');
```

**Get all countries**
```javascript
console.log(countries.getAllCountries());
console.log(iso3166Lookup.getAllCountries());
/** Returns:
[
{
Expand All @@ -42,7 +42,7 @@ console.log(countries.getAllCountries());

**Find country by country name**
```javascript
console.log(countries.findCountry('India'));
console.log(iso3166Lookup.findCountry('India'));
/** Returns:
{
country: 'India',
Expand All @@ -55,7 +55,7 @@ console.log(countries.findCountry('India'));

**Find country by ISO 3166-1 Alpha-2**
```javascript
console.log(countries.findAlpha2('in'));
console.log(iso3166Lookup.findAlpha2('in'));
/** Returns:
{
country: 'India',
Expand All @@ -68,7 +68,7 @@ console.log(countries.findAlpha2('in'));

**Find country by ISO 3166-1 Alpha-3**
```javascript
console.log(countries.findAlpha3('ind'));
console.log(iso3166Lookup.findAlpha3('ind'));
/** Returns:
{
country: 'India',
Expand All @@ -81,7 +81,7 @@ console.log(countries.findAlpha3('ind'));

**Find country by ISO 3166-1 Num-3 (Numeric)**
```javascript
console.log(countries.findNum3(356));
console.log(iso3166Lookup.findNum3(356));
/** Returns:
{
country: 'India',
Expand Down
28 changes: 14 additions & 14 deletions test/test.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import { expect } from "chai";
import { describe, it } from "mocha";
import iso from "../dist/";
import iso3166Lookup from "../dist/";
import countries from "../dist/countries";

describe("Tests for ISO-3166-1 lookup features", function () {
describe("Get all from list", function () {
it("returns an array of all countries", function () {
expect(iso.getAllCountries()).to.be.equal(countries);
expect(iso3166Lookup.getAllCountries()).to.be.equal(countries);
});
});

describe("Not existing countries", function () {
it("returns undefined if country not found with country name", function () {
const country = iso.findCountry("Unknown");
const country = iso3166Lookup.findCountry("Unknown");

expect(country).to.be.equal(undefined);
});

it("returns undefined if country not found with alpha-2", function () {
const country = iso.findAlpha2("xx");
const country = iso3166Lookup.findAlpha2("xx");

expect(country).to.be.equal(undefined);
});

it("returns undefined if country not found with alpha-3", function () {
const country = iso.findAlpha2("xxx");
const country = iso3166Lookup.findAlpha2("xxx");

expect(country).to.be.equal(undefined);
});

it("returns undefined if country not found with num-3", function () {
const country = iso.findNum3("999");
const country = iso3166Lookup.findNum3("999");

expect(country).to.be.equal(undefined);
});
});

describe("Supplying country name as param", function () {
it("returns a country by country name with uppercase letters", function () {
const country = iso.findCountry("INDIA");
const country = iso3166Lookup.findCountry("INDIA");

expect(country).to.have.deep.property("country", "India");
expect(country).to.have.deep.property("alpha2", "IN");
Expand All @@ -47,7 +47,7 @@ describe("Tests for ISO-3166-1 lookup features", function () {
});

it("returns a country by country name with lowercase letters", function () {
const country = iso.findCountry("norway");
const country = iso3166Lookup.findCountry("norway");

expect(country).to.have.deep.property("country", "Norway");
expect(country).to.have.deep.property("alpha2", "NO");
Expand All @@ -58,7 +58,7 @@ describe("Tests for ISO-3166-1 lookup features", function () {

describe("Supplying alpha-2 as param", function () {
it("returns a country by alpha-2 with lowercase letters", function () {
const country = iso.findAlpha2("ax");
const country = iso3166Lookup.findAlpha2("ax");

expect(country).to.have.deep.property("country", "Åland Islands");
expect(country).to.have.deep.property("alpha2", "AX");
Expand All @@ -67,7 +67,7 @@ describe("Tests for ISO-3166-1 lookup features", function () {
});

it("returns a country by alpha-2 with uppercase letters", function () {
const country = iso.findAlpha2("BA");
const country = iso3166Lookup.findAlpha2("BA");

expect(country).to.have.deep.property(
"country",
Expand All @@ -81,7 +81,7 @@ describe("Tests for ISO-3166-1 lookup features", function () {

describe("Supplying alpha-3 as param", function () {
it("returns a country by alpha-3 with lowercase letters", function () {
const country = iso.findAlpha3("asm");
const country = iso3166Lookup.findAlpha3("asm");

expect(country).to.have.deep.property("country", "American Samoa");
expect(country).to.have.deep.property("alpha2", "AS");
Expand All @@ -90,7 +90,7 @@ describe("Tests for ISO-3166-1 lookup features", function () {
});

it("returns a country by alpha-3 with uppercase letters", function () {
const country = iso.findAlpha3("ATG");
const country = iso3166Lookup.findAlpha3("ATG");

expect(country).to.have.deep.property("country", "Antigua and Barbuda");
expect(country).to.have.deep.property("alpha2", "AG");
Expand All @@ -101,7 +101,7 @@ describe("Tests for ISO-3166-1 lookup features", function () {

describe("Supplying num-3 as param", function () {
it("returns a country by num-3 (integer)", function () {
const country = iso.findNum3(616);
const country = iso3166Lookup.findNum3(616);

expect(country).to.have.deep.property("country", "Poland");
expect(country).to.have.deep.property("alpha2", "PL");
Expand All @@ -110,7 +110,7 @@ describe("Tests for ISO-3166-1 lookup features", function () {
});

it("returns a country by num-3 (string)", function () {
const country = iso.findNum3("036");
const country = iso3166Lookup.findNum3("036");

expect(country).to.have.deep.property("country", "Australia");
expect(country).to.have.deep.property("alpha2", "AU");
Expand Down

0 comments on commit 79d237b

Please sign in to comment.