-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
2c3e4b8
commit bd489a9
Showing
22 changed files
with
1,403 additions
and
886 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
NPM_TOKEN= |
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,63 @@ | ||
name: Publish to npm and create GitHub Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Build package | ||
run: yarn build | ||
|
||
- name: Get the latest tag | ||
id: get_latest_tag | ||
run: echo ::set-output name=tag::$(git describe --tags `git rev-list --tags --max-count=1`) | ||
|
||
- name: Calculate new tag | ||
id: new_tag | ||
run: | | ||
echo "Current tag: ${{ steps.get_latest_tag.outputs.tag }}" | ||
NEW_TAG=$(echo ${{ steps.get_latest_tag.outputs.tag }} | awk -F. -v OFS=. '{$NF += 1 ; print}') | ||
echo "New tag: $NEW_TAG" | ||
echo ::set-output name=tag::$NEW_TAG | ||
- name: Publish to npm | ||
run: yarn publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Create GitHub Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.new_tag.outputs.tag }} | ||
release_name: Release ${{ steps.new_tag.outputs.tag }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./dist/index.js | ||
asset_name: index.js | ||
asset_content_type: application/javascript |
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,19 +1,44 @@ | ||
# Node modules | ||
node_modules | ||
node_modules/ | ||
|
||
# Build output | ||
dist | ||
dist/ | ||
|
||
# Logs | ||
logs | ||
coverage/ | ||
jest-config.js | ||
jest.setup.js | ||
|
||
logs/ | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Editor directories and files | ||
.DS_Store | ||
Thumbs.db | ||
.vscode/ | ||
.idea/ | ||
*.sublime-project | ||
*.sublime-workspace | ||
.DS_Store | ||
|
||
*.tgz | ||
|
||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
.env | ||
|
||
.npm/ | ||
*.cache | ||
|
||
.cache/ | ||
.next/ | ||
|
||
coverage/ | ||
|
||
test-results/ | ||
|
||
*.tmp | ||
*.temp | ||
|
||
build/ | ||
|
||
.npmrc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { EntityItem } from "../../entities/entity-item.entity"; | ||
|
||
describe("EntityItem Interface", () => { | ||
it("should allow a string label and value", () => { | ||
const item: EntityItem = { | ||
label: "Test Label", | ||
value: "Test Value", | ||
}; | ||
|
||
expect(item.label).toBe("Test Label"); | ||
expect(item.value).toBe("Test Value"); | ||
}); | ||
|
||
it("should allow a string label and a number value", () => { | ||
const item: EntityItem = { | ||
label: "Test Label", | ||
value: 123, | ||
}; | ||
|
||
expect(item.label).toBe("Test Label"); | ||
expect(item.value).toBe(123); | ||
}); | ||
}); |
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,61 @@ | ||
import { | ||
ContentTypes, | ||
HttpMethods, | ||
ResponseEncodings, | ||
ResponseHeaders, | ||
ResponseTypes, | ||
} from "../../enums/http.enum"; | ||
|
||
describe("HTTP Enums", () => { | ||
it("should have correct values for ContentTypes", () => { | ||
expect(ContentTypes.Html).toBe("text/html"); | ||
expect(ContentTypes.Plain).toBe("text/plain"); | ||
expect(ContentTypes.FormData).toBe("multipart/form-data"); | ||
expect(ContentTypes.Json).toBe("application/json"); | ||
expect(ContentTypes.UrlEncoded).toBe("application/x-www-form-urlencoded"); | ||
expect(ContentTypes.OctetStream).toBe("application/octet-stream"); | ||
}); | ||
|
||
it("should have correct values for ResponseHeaders", () => { | ||
expect(ResponseHeaders.Server).toBe("Server"); | ||
expect(ResponseHeaders.ContentType).toBe("Content-Type"); | ||
expect(ResponseHeaders.ContentLength).toBe("Content-Length"); | ||
expect(ResponseHeaders.CacheControl).toBe("Cache-Control"); | ||
expect(ResponseHeaders.ContentEncoding).toBe("Content-Encoding"); | ||
}); | ||
|
||
it("should have correct values for HttpMethods", () => { | ||
expect(HttpMethods.Get).toBe("GET"); | ||
expect(HttpMethods.Delete).toBe("DELETE"); | ||
expect(HttpMethods.Head).toBe("HEAD"); | ||
expect(HttpMethods.Options).toBe("OPTIONS"); | ||
expect(HttpMethods.Post).toBe("POST"); | ||
expect(HttpMethods.Put).toBe("PUT"); | ||
expect(HttpMethods.Patch).toBe("PATCH"); | ||
expect(HttpMethods.Purge).toBe("PURGE"); | ||
expect(HttpMethods.Link).toBe("LINK"); | ||
expect(HttpMethods.Unlink).toBe("UNLINK"); | ||
}); | ||
|
||
it("should have correct values for ResponseTypes", () => { | ||
expect(ResponseTypes.ArrayBuffer).toBe("arraybuffer"); | ||
expect(ResponseTypes.Blob).toBe("blob"); | ||
expect(ResponseTypes.Document).toBe("document"); | ||
expect(ResponseTypes.Json).toBe("json"); | ||
expect(ResponseTypes.Text).toBe("text"); | ||
expect(ResponseTypes.Stream).toBe("stream"); | ||
}); | ||
|
||
it("should have correct values for ResponseEncodings", () => { | ||
expect(ResponseEncodings.Ascii).toBe("ascii"); | ||
expect(ResponseEncodings.Ansi).toBe("ansi"); | ||
expect(ResponseEncodings.Binary).toBe("binary"); | ||
expect(ResponseEncodings.Base64).toBe("base64"); | ||
expect(ResponseEncodings.Base64Url).toBe("base64url"); | ||
expect(ResponseEncodings.Hex).toBe("hex"); | ||
expect(ResponseEncodings.Latin1).toBe("latin1"); | ||
expect(ResponseEncodings.Ucs2).toBe("ucs-2"); | ||
expect(ResponseEncodings.Utf8).toBe("utf-8"); | ||
expect(ResponseEncodings.Utf16le).toBe("utf16le"); | ||
}); | ||
}); |
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,11 @@ | ||
import { TimeDurations } from "../../enums/time-duration.enum"; | ||
|
||
describe("TimeDurations Enum", () => { | ||
it("should have correct values", () => { | ||
expect(TimeDurations.HalfSecond).toBe(500); | ||
expect(TimeDurations.OneMinute).toBe(60000); | ||
expect(TimeDurations.TwoMinutes).toBe(120000); | ||
expect(TimeDurations.FiveMinutes).toBe(300000); | ||
expect(TimeDurations.OneDay).toBe(86400000); | ||
}); | ||
}); |
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,56 @@ | ||
import { | ||
getFirstTwoWords, | ||
getFirstWord, | ||
getInitials, | ||
getLastWord, | ||
getPluralOrSingular, | ||
isShortWord, | ||
} from "../../helpers/string.helper"; | ||
|
||
describe("String Utilities", () => { | ||
it("should get the first word", () => { | ||
expect(getFirstWord("hello world")).toBe("hello"); | ||
expect(getFirstWord("hello")).toBe("hello"); | ||
expect(getFirstWord(" hello ")).toBe("hello"); | ||
}); | ||
|
||
it("should get the last word", () => { | ||
expect(getLastWord("hello world")).toBe("world"); | ||
expect(getLastWord("world")).toBe("world"); | ||
expect(getLastWord(" world ")).toBe("world"); | ||
}); | ||
|
||
it("should get the first two words", () => { | ||
expect(getFirstTwoWords("hello beautiful world")).toBe("hello beautiful"); | ||
expect(getFirstTwoWords("hello")).toBe("hello"); | ||
expect(getFirstTwoWords("hello beautiful world", false)).toBe( | ||
"hello beautiful" | ||
); | ||
expect(getFirstTwoWords("hello the world", true)).toBe("hello the world"); | ||
expect(getFirstTwoWords("hello the the world", true)).toBe( | ||
"hello the the world" | ||
); | ||
}); | ||
|
||
it("should identify short words correctly", () => { | ||
expect(isShortWord("the")).toBe(true); | ||
expect(isShortWord("a")).toBe(true); | ||
expect(isShortWord("no")).toBe(true); | ||
expect(isShortWord("hello")).toBe(false); | ||
expect(isShortWord("world")).toBe(false); | ||
}); | ||
|
||
it("should return plural or singular based on count", () => { | ||
expect(getPluralOrSingular(1, "apple", "apples")).toBe("1 apple"); | ||
expect(getPluralOrSingular(2, "apple", "apples")).toBe("2 apples"); | ||
expect(getPluralOrSingular(0, "apple", "apples")).toBe(""); | ||
}); | ||
|
||
it("should get initials from text", () => { | ||
expect(getInitials("John Doe")).toBe("JD"); | ||
expect(getInitials("SingleName")).toBe("S"); | ||
expect(getInitials(" John Doe ")).toBe("JD"); | ||
expect(getInitials("John the Doe")).toBe("JD"); | ||
expect(getInitials("John the the Doe")).toBe("JD"); | ||
}); | ||
}); |
Oops, something went wrong.