This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
93 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ install: | |
- "yarn" | ||
script: | ||
- "yarn build" | ||
- "yarn test" | ||
env: | ||
- YARN_GPG=no |
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,11 +1,12 @@ | ||
{ | ||
"name": "staart-manager", | ||
"version": "1.0.62", | ||
"version": "1.0.65", | ||
"main": "index.js", | ||
"repository": "[email protected]:AnandChowdhary/staart.git", | ||
"author": "Anand Chowdhary <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "jest", | ||
"build": "touch .env && mkdir -p dist && cp .env dist/.env && npm run generate-routes && tsc", | ||
"build-babel": "touch .env && babel src -d dist --extensions '.ts' && cp .env dist/.env", | ||
"start": "npm run build-babel && node dist/index.js", | ||
|
@@ -30,6 +31,14 @@ | |
"engines": { | ||
"node": "10.16.0" | ||
}, | ||
"jest": { | ||
"roots": [ | ||
"<rootDir>/src" | ||
], | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.5.0", | ||
"@babel/core": "^7.5.4", | ||
|
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 +1 @@ | ||
1.0.62 | ||
1.0.65 |
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,33 @@ | ||
import { getGeolocationFromIp } from "../location"; | ||
|
||
test("Gets a location from IP address", async () => { | ||
const location = await getGeolocationFromIp("103.101.26.51"); | ||
expect(location).toBeDefined(); | ||
}); | ||
|
||
test("Gets city from IP address", async () => { | ||
const location = await getGeolocationFromIp("103.101.26.51"); | ||
expect(location && location.city).toContain("Delhi"); | ||
}); | ||
|
||
test("Gets continent from IP address", async () => { | ||
const location = await getGeolocationFromIp("103.101.26.51"); | ||
expect(location && location.continent).toBe("Asia"); | ||
}); | ||
|
||
test("Gets country from IP address", async () => { | ||
const location = await getGeolocationFromIp("103.101.26.51"); | ||
expect(location && location.country_code).toBe("IN"); | ||
}); | ||
|
||
test("Gets timezone from IP address", async () => { | ||
const location = await getGeolocationFromIp("103.101.26.51"); | ||
expect(location && location.time_zone).toBe("Asia/Kolkata"); | ||
}); | ||
|
||
test("Gets region from IP address", async () => { | ||
const location = await getGeolocationFromIp("103.101.26.51"); | ||
expect(location && location.region_name).toBe( | ||
"National Capital Territory of Delhi" | ||
); | ||
}); |
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,45 @@ | ||
import { | ||
capitalizeEachFirstLetter, | ||
capitalizeFirstAndLastLetter, | ||
capitalizeFirstLetter, | ||
dateToDateTime, | ||
deleteSensitiveInfoUser, | ||
anonymizeIpAddress, | ||
createSlug | ||
} from "../utils"; | ||
|
||
test("Capitalize name", () => { | ||
expect(capitalizeEachFirstLetter("anand chowdhary")).toBe("Anand Chowdhary"); | ||
}); | ||
|
||
test("Capitalize name", () => { | ||
expect(capitalizeFirstAndLastLetter("johannes van der waals")).toBe( | ||
"Johannes van der Waals" | ||
); | ||
}); | ||
|
||
test("Capitalize first letter", () => { | ||
expect(capitalizeFirstLetter("anand chowdhary")).toBe("Anand chowdhary"); | ||
}); | ||
|
||
test("Convert date to MySQL datetime", () => { | ||
expect(dateToDateTime(new Date(1563170490000))).toBe("2019-07-15 06:01:30"); | ||
}); | ||
|
||
test("Remove sensitive info", () => { | ||
expect( | ||
deleteSensitiveInfoUser({ | ||
id: 1, | ||
name: "Anand Chowdhary", | ||
password: "1abc9c" | ||
}).password | ||
).toBeUndefined(); | ||
}); | ||
|
||
test("Anonymize an IP address", () => { | ||
expect(anonymizeIpAddress("103.101.26.51")).toBe("103.101.26.0"); | ||
}); | ||
|
||
test("Create a slug", () => { | ||
expect(createSlug("Anand Chowdhary")).toContain("anand-chowdhary-"); | ||
}); |
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