-
Notifications
You must be signed in to change notification settings - Fork 621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(internal): improve test coverage #4779
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fa8e918
test(internal): improve test coverage
mbhrznr f0aab50
Merge branch 'main' into test/internal
mbhrznr c4015e3
test(internal): improve test coverage
mbhrznr 60144db
Merge branch 'main' into test/internal
mbhrznr 96dc7b9
test(internal): implement review remarks
mbhrznr 9e8e448
Merge branch 'test/internal' of github.com:mbhrznr/deno_std into test…
mbhrznr 35c053d
Merge branch 'main' into test/internal
mbhrznr 2497e99
test(internal): implement review remarks
mbhrznr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. | ||
import { assertEquals } from "@std/assert"; | ||
import { bgGreen, bgRed, bold, gray, green, red, white } from "@std/fmt/colors"; | ||
import { _internals, buildMessage } from "./build_message.ts"; | ||
|
||
const { createColor, createSign } = _internals; | ||
|
||
Deno.test("buildMessage()", () => { | ||
const messages = [ | ||
"", | ||
"", | ||
` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${ | ||
green(bold("Expected")) | ||
}`, | ||
"", | ||
"", | ||
]; | ||
assertEquals(buildMessage([]), [...messages, ""]); | ||
assertEquals( | ||
buildMessage([{ type: "added", value: "foo" }, { | ||
type: "removed", | ||
value: "bar", | ||
}]), | ||
[...messages, green(bold("+ foo")), red(bold("- bar")), ""], | ||
); | ||
}); | ||
|
||
Deno.test("createColor()", () => { | ||
assertEquals(createColor("added")("foo"), green(bold("foo"))); | ||
assertEquals(createColor("removed")("foo"), red(bold("foo"))); | ||
assertEquals(createColor("common")("foo"), white("foo")); | ||
assertEquals(createColor("added", true)("foo"), bgGreen(white("foo"))); | ||
assertEquals(createColor("removed", true)("foo"), bgRed(white("foo"))); | ||
assertEquals(createColor("common", true)("foo"), white("foo")); | ||
}); | ||
|
||
Deno.test("createSign()", () => { | ||
assertEquals(createSign("added"), "+ "); | ||
assertEquals(createSign("removed"), "- "); | ||
assertEquals(createSign("common"), " "); | ||
// deno-lint-ignore no-explicit-any | ||
assertEquals(createSign("unknown" as any), " "); | ||
}); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's export these functions instead of putting them in these
_internals
objects. It'll be much cleaner. Ditto for the other files in this package. This is fine to do here as this is purely an internal package. You'll have to add@example
tags to the newly exported symbols to make the doc checker (deno task lint:docs
) too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha!
for some reason i was unsure if we would ever want to export the other functions in this package.
implemented as suggested.
love the way how the doc checker works bth!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you able to fix the functions in this file too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh... i'm so sorry.
cleanup for
build_message
is done as well.