Skip to content

Commit

Permalink
Meta: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispuska committed Jan 6, 2024
1 parent 6f3ee37 commit 22a6152
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 30 deletions.
4 changes: 1 addition & 3 deletions packages/utils/colors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ describe("colors", () => {
it("converts rgb to hex", () =>
expect(rgbToHex(12, 44, 120)).toEqual("#0c2c78"))
it("converts string to hex", () =>
expect(rgbToHex(<any>"12", <any>"44", <any>"120")).toEqual(
"#0c2c78",
))
expect(rgbToHex(<any>"12", <any>"44", <any>"120")).toEqual("#0c2c78"))
it("converts null to hex", () =>
expect(rgbToHex(<any>null, 44, 120)).toEqual("#002c78"))
it("returns undefined to hex", () =>
Expand Down
7 changes: 2 additions & 5 deletions packages/utils/slug.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ describe("slug", () => {
it("returns valid from special string", () =>
expect(getSlug("#$%^B#uR#n-")).toEqual("burn-"))
it("returns valid from parens string", () =>
expect(getSlug("Gaussian Blur [1](2){3}")).toEqual(
"gaussian-blur-123",
))
expect(getSlug("Gaussian Blur [1](2){3}")).toEqual("gaussian-blur-123"))
it("replaces àáäâèéëêìíïîòóöôùúüûñç", () =>
expect(getSlug("àáäâèéëêìíïîòóöôùúüûñç")).toEqual(
"aaaaeeeeiiiioooouuuunc",
))
it("fails silently from undefined", () =>
expect(getSlug(undefined)).toEqual(""))
it("fails silently from null", () =>
expect(getSlug(<any>null)).toEqual(""))
it("fails silently from null", () => expect(getSlug(<any>null)).toEqual(""))
})
})
10 changes: 4 additions & 6 deletions packages/utils/strings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ describe("strings", () => {
"a link hello",
))
it("removes a bold link", () =>
expect(
removeMarkdown("a [bold **link**](https://x.com) hello"),
).toEqual("a bold link hello"))
expect(removeMarkdown("a [bold **link**](https://x.com) hello")).toEqual(
"a bold link hello",
))
})

describe("middleEllipsis", () => {
it("works with short word", () =>
expect(middleEllipsis("ellipsis", 5)).toEqual("e...s"))
it("works with longer word", () =>
expect(middleEllipsis("lorem ipsum dolor", 12)).toEqual(
"lore...olor",
))
expect(middleEllipsis("lorem ipsum dolor", 12)).toEqual("lore...olor"))
it("fails silently for undefined", () =>
expect(middleEllipsis(<any>null, 12)).toEqual(""))
})
Expand Down
10 changes: 3 additions & 7 deletions packages/utils/uuid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ describe("validations", () => {
describe("getUUID", () => {
const MOCK_UUID = getUUID()

it("returns test uuid", () =>
expect(getUUID(MOCK_UUID)).toEqual(TEST_UUID))
it("returns test uuid", () => expect(getUUID(MOCK_UUID)).toEqual(TEST_UUID))
it("returns any string", () =>
expect(getUUID("any-string")).toEqual("any-string"))
})

describe("isUUID", () => {
it("validates test uuid", () => expect(isUUID(TEST_UUID)).toEqual(true))
it("validates a random uuid", () =>
expect(isUUID("101bfe56-8c16-4f94-9b45-759ea5e67cea")).toEqual(
true,
))
expect(isUUID("101bfe56-8c16-4f94-9b45-759ea5e67cea")).toEqual(true))
it("catches empty string", () => expect(isUUID("")).toEqual(false))
it("catches undefined", () =>
expect(isUUID(<any>undefined)).toEqual(false))
it("catches undefined", () => expect(isUUID(<any>undefined)).toEqual(false))
})
})
13 changes: 4 additions & 9 deletions packages/utils/validations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import { it, describe, expect } from "vitest"

describe("validations", () => {
describe("validateEmail", () => {
it("validates email", () =>
expect(validateEmail("x@x.com")).toEqual(true))
it("validates email", () => expect(validateEmail("x@x.com")).toEqual(true))
it("validates email with +", () =>
expect(validateEmail("x+x@x.com")).toEqual(true))
it("validates email with long tld", () =>
expect(validateEmail("0@helios.graphics")).toEqual(true))
it("catches long invalid string", () =>
expect(validateEmail("@space.city")).toEqual(false))
it("catches empty string", () =>
expect(validateEmail("")).toEqual(false))
it("catches empty string", () => expect(validateEmail("")).toEqual(false))
it("catches undefined", () =>
expect(validateEmail(<any>undefined)).toEqual(false))
it("catches multi @", () =>
Expand All @@ -25,9 +23,7 @@ describe("validations", () => {
it("validates url", () =>
expect(validateHttpUrl("https://x.com")).toEqual(true))
it("validates url with long tld", () =>
expect(validateHttpUrl("https://lorem-ipsum.graphics")).toEqual(
true,
))
expect(validateHttpUrl("https://lorem-ipsum.graphics")).toEqual(true))
it("validates url with double subdomain", () =>
expect(validateHttpUrl("https://0.x.x.com")).toEqual(true))
it("catches ftp", () =>
Expand All @@ -36,8 +32,7 @@ describe("validations", () => {
expect(validateHttpUrl("lorem ipsum https://x.com")).toEqual(false))
it("catches unsafe http", () =>
expect(validateHttpUrl("http://x.com")).toEqual(false))
it("catches empty string", () =>
expect(validateHttpUrl("")).toEqual(false))
it("catches empty string", () => expect(validateHttpUrl("")).toEqual(false))
it("catches undefined", () =>
expect(validateHttpUrl(<any>undefined)).toEqual(false))
})
Expand Down

0 comments on commit 22a6152

Please sign in to comment.