Skip to content

Commit

Permalink
try to remove colors manually
Browse files Browse the repository at this point in the history
  • Loading branch information
vaaski committed Jul 19, 2024
1 parent b60df03 commit b7e51b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions tests/_shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const removeColors = (text: string) =>
text.replace(
// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
"",
)
8 changes: 4 additions & 4 deletions tests/help.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from "bun:test"
import { reset } from "kolorist"
import { removeColors } from "./_shared"

const helpOutput = `
Usage: localpen [options]
Expand Down Expand Up @@ -34,7 +34,7 @@ test("print help message", async () => {

await child.exited

expect(reset(text)).toBe(helpOutput)
expect(removeColors(text)).toBe(helpOutput)
})

test("print help message on wrong template", async () => {
Expand All @@ -43,6 +43,6 @@ test("print help message on wrong template", async () => {

await child.exited

expect(reset(text)).toContain(helpOutput)
expect(reset(text)).toContain(" not found")
expect(removeColors(text)).toContain(helpOutput)
expect(removeColors(text)).toContain(" not found")
})

0 comments on commit b7e51b0

Please sign in to comment.