Skip to content

Commit

Permalink
add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Sep 10, 2024
1 parent d0c99a2 commit ff3d3ac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/effect/test/Mailbox.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Effect, Exit, Fiber, Mailbox } from "effect"
import { Chunk, Effect, Exit, Fiber, Mailbox, Stream } from "effect"
import { assert, describe, it } from "effect/test/utils/extend"

describe("Mailbox", () => {
Expand Down Expand Up @@ -70,4 +70,15 @@ describe("Mailbox", () => {
yield* mailbox.done(Exit.void)
assert.deepStrictEqual(yield* fiber.await, Exit.succeed([[] as Array<number>, true] as const))
}))

it.effect("offer ordering", () =>
Effect.gen(function*() {
const mailbox = yield* Mailbox.make<number>(2)
yield* Effect.fork(mailbox.offerAll([1, 2, 3, 4]))
yield* Effect.fork(mailbox.offerAll([5, 6, 7, 8]))
yield* Effect.fork(mailbox.offer(9))
yield* Effect.fork(mailbox.end)
const items = yield* Stream.runCollect(Mailbox.toStream(mailbox))
assert.deepStrictEqual(Chunk.toReadonlyArray(items), [1, 2, 3, 4, 5, 6, 7, 8, 9])
}))
})

0 comments on commit ff3d3ac

Please sign in to comment.