-
-
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
Showing
5 changed files
with
38 additions
and
25 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
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 |
---|---|---|
|
@@ -3,13 +3,19 @@ | |
"version": "1.0.0-alpha.1", | ||
|
||
"imports": { | ||
"@crayon/crayon": "jsr:/@crayon/[email protected].2", | ||
"@crayon/crayon": "jsr:/@crayon/[email protected].3", | ||
// tests | ||
"@cross/test": "jsr:@cross/[email protected]", | ||
"@std/assert": "jsr:@std/[email protected]" | ||
"@beast/compat": "jsr:@beast/compat@^0.2.5", | ||
"@std/assert": "jsr:@std/assert@^0.221.0" | ||
}, | ||
"exports": "./main.ts", | ||
|
||
"tasks": { | ||
"test-all": "deno task test && deno task test-nocolor", | ||
"test": "deno test --fail-fast=1 --allow-env", | ||
"test-nocolor": "NO_COLOR=1 deno task test" | ||
}, | ||
|
||
"fmt": { | ||
"lineWidth": 100 | ||
}, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,22 +1,35 @@ | ||
// Copyright 2024 Im-Beast. All rights reserved. MIT license. | ||
import { test } from "@cross/test"; | ||
import { env, test } from "@beast/compat"; | ||
import { assert, assertEquals, assertThrows } from "@std/assert"; | ||
|
||
import crayon from "@crayon/crayon"; | ||
import "./main.ts"; | ||
|
||
test("Literal", () => { | ||
const NO_COLOR = !!(env("NO_COLOR") && env("NO_COLOR") !== "0"); | ||
|
||
test.ignoreIf(!NO_COLOR)("NO_COLOR Literal", () => { | ||
assertEquals(crayon`{bold.rgb(255) {red Hello {yellow world}}}`, "Hello world"); | ||
}); | ||
|
||
test.ignoreIf(NO_COLOR)("Literal", () => { | ||
assert(crayon`{red {bold Hello} world!}`.endsWith("\x1b[0m")); | ||
assertEquals( | ||
crayon`{red {bold Hello} world!}`, | ||
"\x1b[31m\x1b[1mHello\x1b[0m\x1b[31m world!\x1b[0m", | ||
); | ||
|
||
const styledText = "{rgb(255,0,17) methods {bgRgb(127,255,0) work!}}"; | ||
assertEquals( | ||
crayon`${styledText}`, | ||
crayon`{rgb(255,0,17) methods {bgRgb(127,255,0) work!}}`, | ||
); | ||
|
||
assertEquals( | ||
crayon`{rgb(255,0,17) methods {bgRgb(127,255,0) work!}}`, | ||
"\x1b[38;2;255;0;17mmethods \x1b[48;2;127;255;0mwork!\x1b[0m\x1b[38;2;255;0;17m\x1b[0m", | ||
); | ||
}); | ||
|
||
test("Errors", () => { | ||
test.ignoreIf(NO_COLOR)("Errors", () => { | ||
assertThrows(() => crayon`{inexistentStyle xyz}`); | ||
}); |