-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add UriComponent schemas and encoding (#3982)
Co-authored-by: Sebastian Lorenz <[email protected]>
- Loading branch information
Showing
6 changed files
with
209 additions
and
0 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,5 @@ | ||
--- | ||
"effect": minor | ||
--- | ||
|
||
Added encodeUriComponent/decodeUriComponent for both Encoding and Schema |
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
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
32 changes: 32 additions & 0 deletions
32
packages/effect/test/Schema/Schema/String/StringFromUriComponent.test.ts
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,32 @@ | ||
import * as S from "effect/Schema" | ||
import * as Util from "effect/test/Schema/TestUtils" | ||
import { describe, it } from "vitest" | ||
|
||
describe("StringFromUriComponent", () => { | ||
const schema = S.StringFromUriComponent | ||
|
||
it("encoding", async () => { | ||
await Util.expectEncodeSuccess(schema, "шеллы", "%D1%88%D0%B5%D0%BB%D0%BB%D1%8B") | ||
await Util.expectEncodeFailure( | ||
schema, | ||
"Hello\uD800", | ||
`StringFromUriComponent | ||
└─ Transformation process failure | ||
└─ URI malformed` | ||
) | ||
}) | ||
|
||
it("decoding", async () => { | ||
await Util.expectDecodeUnknownSuccess(schema, "%D1%88%D0%B5%D0%BB%D0%BB%D1%8B", "шеллы") | ||
await Util.expectDecodeUnknownSuccess(schema, "hello", "hello") | ||
await Util.expectDecodeUnknownSuccess(schema, "hello%20world", "hello world") | ||
|
||
await Util.expectDecodeUnknownFailure( | ||
schema, | ||
"Hello%2world", | ||
`StringFromUriComponent | ||
└─ Transformation process failure | ||
└─ URI malformed` | ||
) | ||
}) | ||
}) |