Skip to content

Commit

Permalink
🔧 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonBoy committed Dec 31, 2019
1 parent e6a15ef commit e3a9591
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 12 additions & 0 deletions __tests__/ChinaLocation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ describe('ChinaLocation', function() {
expect(newLocation.district.name).toEqual('吴江区');
});

it('should get current provinces/cities/districts', function() {
const location = new ChinaLocation(list);
//shanghai
location.changeLocation('310000', '310000', '310101');
const provinces = location.getCurrentProvinces();
const cities = location.getCurrentCities();
const districts = location.getCurrentDistricts();
expect(provinces.length).toEqual(34);
expect(cities.length).toEqual(1);
expect(districts.length).toEqual(16);
});

it('should have no district', function() {
const location = new ChinaLocation(list);
location.changeLocation('440000', '441900');
Expand Down
3 changes: 0 additions & 3 deletions lib/ChinaLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class ChinaLocation {
activeDistrict: string;

constructor(locationData) {
if (!(this instanceof ChinaLocation)) {
return new ChinaLocation(locationData);
}

this.locationData = locationData;

Expand Down

0 comments on commit e3a9591

Please sign in to comment.