diff --git a/__tests__/ChinaLocation.test.ts b/__tests__/ChinaLocation.test.ts index d3656a9..79438b4 100644 --- a/__tests__/ChinaLocation.test.ts +++ b/__tests__/ChinaLocation.test.ts @@ -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'); diff --git a/lib/ChinaLocation.ts b/lib/ChinaLocation.ts index 13acd47..264b62f 100644 --- a/lib/ChinaLocation.ts +++ b/lib/ChinaLocation.ts @@ -26,9 +26,6 @@ class ChinaLocation { activeDistrict: string; constructor(locationData) { - if (!(this instanceof ChinaLocation)) { - return new ChinaLocation(locationData); - } this.locationData = locationData;