Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/effect/test/TestClock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as Duration from "effect/Duration"
import * as Effect from "effect/Effect"
import * as Exit from "effect/Exit"
import * as Fiber from "effect/Fiber"
import * as Layer from "effect/Layer"
import * as Scheduler from "effect/Scheduler"
import * as TestClock from "effect/testing/TestClock"
import * as TestConsole from "effect/testing/TestConsole"
Expand All @@ -13,7 +14,7 @@ import { vi } from "vitest"
describe("TestClock", () => {
describe("warnings", { concurrent: false }, () => {
for (const warning of ["not advancing the test clock", "still running without suspending"] as const) {
it.effect(`warnings bypass TestConsole - ${warning}`, () =>
it.live(`warnings bypass TestConsole - ${warning}`, () =>
Effect.gen(function*() {
const output: Array<unknown> = []
yield* Effect.acquireRelease(
Expand Down Expand Up @@ -48,7 +49,11 @@ describe("TestClock", () => {
}).pipe(Effect.timeout("3 seconds"), TestClock.withLive)
assert.deepStrictEqual(captured, ["ordinary output"])
assert.isTrue(containsWarning(output))
}))
}).pipe(
// The environment `it.effect` provides, with a shorter warning delay. `it.live`
// starts without TestConsole, so the clock captures the real console.
Effect.provide(Layer.mergeAll(TestConsole.layer, TestClock.layer({ warningDelay: "10 millis" })))
))
}
})

Expand Down
3 changes: 2 additions & 1 deletion packages/effect/test/cluster/ClusterWorkflowEngine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,8 @@ describe.concurrent("ClusterWorkflowEngine", () => {
name: "a durable clock",
saves: (envelope: Message.OutgoingRequest<any>) =>
envelope.envelope.address.entityType === "Workflow/-/DurableClock",
body: Effect.as(DurableClock.sleep({ name: "Wait", duration: "1 second", inMemoryThreshold: 0 }), 42)
// Long enough to still be pending when the first save retry runs.
body: Effect.as(DurableClock.sleep({ name: "Wait", duration: "300 millis", inMemoryThreshold: 0 }), 42)
},
{
name: "a durable race winner",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,16 @@ describe("Codegen.Module.addSchemas annotations", () => {
})
})

it("capitalizes a lowercase reference identifier", () => {
const output = makeModule({
representations: [StringRepresentation],
references: { abc: NumberRepresentation }
})
assert.strictEqual(declarationNames(output)[0], "Abc")
it("sanitizes reference identifiers", () => {
const sanitize = (identifier: string) =>
declarationNames(makeModule({
representations: [StringRepresentation],
references: { [identifier]: NumberRepresentation }
}))[0]
assert.deepStrictEqual(
["abc", "Abc", "1a", "a-b", "café", "🤖", ""].map(sanitize),
["Abc", "Abc", "_1a", "A_b", "Caf_", "_", "_"]
)
})

it("preserves a lowercase identifier annotation", () => {
Expand All @@ -448,54 +452,6 @@ describe("Codegen.Module.addSchemas annotations", () => {
})
})

it("preserves an uppercase reference identifier", () => {
const output = makeModule({
representations: [StringRepresentation],
references: { Abc: NumberRepresentation }
})
assert.strictEqual(declarationNames(output)[0], "Abc")
})

it("prefixes a numeric reference identifier", () => {
const output = makeModule({
representations: [StringRepresentation],
references: { "1a": NumberRepresentation }
})
assert.strictEqual(declarationNames(output)[0], "_1a")
})

it("replaces punctuation in a reference identifier", () => {
const output = makeModule({
representations: [StringRepresentation],
references: { "a-b": NumberRepresentation }
})
assert.strictEqual(declarationNames(output)[0], "A_b")
})

it("replaces non-ASCII characters in a reference identifier", () => {
const output = makeModule({
representations: [StringRepresentation],
references: { café: NumberRepresentation }
})
assert.strictEqual(declarationNames(output)[0], "Caf_")
})

it("replaces an emoji reference identifier", () => {
const output = makeModule({
representations: [StringRepresentation],
references: { "🤖": NumberRepresentation }
})
assert.strictEqual(declarationNames(output)[0], "_")
})

it("uses an underscore for an empty reference identifier", () => {
const output = makeModule({
representations: [StringRepresentation],
references: { "": NumberRepresentation }
})
assert.strictEqual(declarationNames(output)[0], "_")
})

it("makes colliding sanitized reference identifiers unique", () => {
const output = makeModule({
representations: [StringRepresentation],
Expand Down
Loading