(layer: Layer.Layer<KeyValueStore.KeyValueStore, E>)
| 4 | import { Effect, identity, Layer, pipe, Schema } from "effect" |
| 5 | |
| 6 | export const testLayer = <E>(layer: Layer.Layer<KeyValueStore.KeyValueStore, E>) => { |
| 7 | const run = <E, A>(effect: Effect.Effect<A, E, KeyValueStore.KeyValueStore>) => |
| 8 | Effect.runPromise(Effect.provide(effect, layer)) |
| 9 | |
| 10 | afterEach(() => |
| 11 | run(Effect.gen(function*() { |
| 12 | const kv = yield* (KeyValueStore.KeyValueStore) |
| 13 | yield* (kv.clear) |
| 14 | })) |
| 15 | ) |
| 16 | |
| 17 | it("set", () => |
| 18 | run(Effect.gen(function*() { |
| 19 | const kv = yield* (KeyValueStore.KeyValueStore) |
| 20 | yield* (kv.set("/foo/bar", "bar")) |
| 21 | |
| 22 | const value = yield* (kv.get("/foo/bar")) |
| 23 | const length = yield* (kv.size) |
| 24 | |
| 25 | assertSome(value, "bar") |
| 26 | strictEqual(length, 1) |
| 27 | }))) |
| 28 | |
| 29 | it("get/ missing", () => |
| 30 | run(Effect.gen(function*() { |
| 31 | const kv = yield* (KeyValueStore.KeyValueStore) |
| 32 | yield* (kv.clear) |
| 33 | const value = yield* (kv.get("foo")) |
| 34 | |
| 35 | assertNone(value) |
| 36 | }))) |
| 37 | |
| 38 | it("remove", () => |
| 39 | run(Effect.gen(function*() { |
| 40 | const kv = yield* (KeyValueStore.KeyValueStore) |
| 41 | yield* (kv.set("foo", "bar")) |
| 42 | yield* (kv.remove("foo")) |
| 43 | |
| 44 | const value = yield* (kv.get("foo")) |
| 45 | const length = yield* (kv.size) |
| 46 | |
| 47 | assertNone(value) |
| 48 | strictEqual(length, 0) |
| 49 | }))) |
| 50 | |
| 51 | it("clear", () => |
| 52 | run(Effect.gen(function*() { |
| 53 | const kv = yield* (KeyValueStore.KeyValueStore) |
| 54 | yield* (kv.set("foo", "bar")) |
| 55 | yield* (kv.clear) |
| 56 | |
| 57 | const value = yield* (kv.get("foo")) |
| 58 | const length = yield* (kv.size) |
| 59 | |
| 60 | assertNone(value) |
| 61 | strictEqual(length, 0) |
| 62 | }))) |
| 63 |
no test coverage detected
searching dependent graphs…