@effect/platform 0.57.5 → 0.57.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -713,6 +713,34 @@ Output:
|
|
|
713
713
|
*/
|
|
714
714
|
```
|
|
715
715
|
|
|
716
|
+
## Testing
|
|
717
|
+
|
|
718
|
+
### Injecting Fetch
|
|
719
|
+
|
|
720
|
+
To test HTTP requests, you can inject a mock fetch implementation.
|
|
721
|
+
|
|
722
|
+
```ts
|
|
723
|
+
import * as Http from "@effect/platform/HttpClient"
|
|
724
|
+
import { Effect, Layer } from "effect"
|
|
725
|
+
import * as assert from "node:assert"
|
|
726
|
+
|
|
727
|
+
// Mock fetch implementation
|
|
728
|
+
const FetchTest = Layer.succeed(Http.client.Fetch, () =>
|
|
729
|
+
Promise.resolve(new Response("not found", { status: 404 }))
|
|
730
|
+
)
|
|
731
|
+
|
|
732
|
+
// Program to test
|
|
733
|
+
const program = Http.request
|
|
734
|
+
.get("https://www.google.com/")
|
|
735
|
+
.pipe(Http.client.fetch, Http.response.text)
|
|
736
|
+
|
|
737
|
+
// Test
|
|
738
|
+
Effect.gen(function* () {
|
|
739
|
+
const response = yield* program
|
|
740
|
+
assert.equal(response, "not found")
|
|
741
|
+
}).pipe(Effect.provide(FetchTest), Effect.runPromise)
|
|
742
|
+
```
|
|
743
|
+
|
|
716
744
|
# HTTP Server
|
|
717
745
|
|
|
718
746
|
## Overview
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/platform",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.6",
|
|
4
4
|
"description": "Unified interfaces for common platform-specific services",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"path-browserify": "^1.0.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@effect/schema": "^0.68.
|
|
18
|
+
"@effect/schema": "^0.68.2",
|
|
19
19
|
"effect": "^3.3.5"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|