-
Notifications
You must be signed in to change notification settings - Fork 178
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 JasonBoy/v2
Migrate to TypeScript
- Loading branch information
Showing
22 changed files
with
10,925 additions
and
2,456 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- stable | ||
script: npm test | ||
- "8" | ||
- "10" | ||
- "stable" | ||
script: npm test |
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,57 @@ | ||
import list from "../dist/location.json"; | ||
import ChinaLocation from "../lib/ChinaLocation"; | ||
|
||
describe("ChinaLocation", function() { | ||
let newProvince: string; | ||
let newCity: string; | ||
let newDistrict: string; | ||
|
||
beforeAll(() => { | ||
newProvince = "320000"; | ||
newCity = "320500"; | ||
newDistrict = "320509"; | ||
}); | ||
|
||
it("should get default location", function() { | ||
const location = new ChinaLocation(list); | ||
const defaultLocation = location.getCurrentAddress(); | ||
expect(defaultLocation.province.code).toEqual("110000"); | ||
expect(defaultLocation.city.code).toEqual("110000"); | ||
expect(defaultLocation.district.code).toEqual("110101"); | ||
}); | ||
|
||
it("should change location", function() { | ||
const location = new ChinaLocation(list); | ||
location.changeProvince(newProvince); | ||
location.changeCity(newCity); | ||
location.changeDistrict(newDistrict); | ||
const newLocation = location.getCurrentAddress(); | ||
expect(newLocation.province.name).toEqual("江苏省"); | ||
expect(newLocation.city.name).toEqual("苏州市"); | ||
expect(newLocation.district.name).toEqual("吴江区"); | ||
}); | ||
|
||
it("should change location at one time", function() { | ||
const location = new ChinaLocation(list); | ||
location.changeLocation(newProvince, newCity, newDistrict); | ||
const newLocation = location.getCurrentAddress(); | ||
expect(newLocation.province.name).toEqual("江苏省"); | ||
expect(newLocation.city.name).toEqual("苏州市"); | ||
expect(newLocation.district.name).toEqual("吴江区"); | ||
}); | ||
|
||
it("should have no district", function() { | ||
const location = new ChinaLocation(list); | ||
location.changeLocation("440000", "441900"); | ||
const newLocation = location.getCurrentAddress(); | ||
expect(newLocation.province.name).toEqual("广东省"); | ||
expect(newLocation.city.name).toEqual("东莞市"); | ||
expect(newLocation.district.name).toEqual(""); | ||
}); | ||
|
||
it("should get new added location", function() { | ||
const location = new ChinaLocation(list); | ||
const district = location.getDistrictByCode("370614", "370600", "370000"); | ||
expect(district).toEqual("蓬莱区"); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.