import assert from "node:assert";
import { test } from "node:test";
import { Clock, Effect, Layer, pipe } from "effect";
const now = new Date();
test("clock", () =>
pipe(
Effect.clock,
Effect.flatMap((clock) => clock.currentTimeMillis),
Effect.map((n) => assert.equal(n, now.getTime())),
Effect.updateService(Clock.Clock, (clock) => ({
...clock,
currentTimeMillis: Effect.succeed(now.getTime()),
})),
Effect.provideLayer(Layer.succeed(Clock.Clock, Clock.make())),
Effect.runSync
));
import assert from "node:assert";
import { test } from "node:test";
import { Clock, Effect, Layer, pipe } from "effect";
const now = new Date();
test("clock", () =>
pipe(
Effect.clock,
Effect.flatMap((clock) => clock.currentTimeMillis),
Effect.map((n) => assert.equal(n, now.getTime())),
Effect.updateService(Clock.Clock, (clock) => ({
...clock,
currentTimeMillis: Effect.succeed(now.getTime()),
})),
Effect.provideLayer(Layer.succeed(Clock.Clock, Clock.make())),
Effect.runSync
));