1import { afterAll, assert, beforeAll, describe, it, layer } from "@effect/vitest"
2import { Effect, Layer, Schema } from "effect"
3import * as Arbitrary from "effect/Arbitrary"
4
5describe("global arbitrary defaults", { concurrent: false }, () => {
6 let plainRuns = 0
7 let effectRuns = 0
8 let layerRuns = 0
9 let overrideRuns = 0
10
11 beforeAll(() => Arbitrary.configureGlobal({ check: { runs: 7 } }))
12 afterAll(() => {
13 Arbitrary.configureGlobal({})
14 assert.strictEqual(plainRuns, 7)
15 assert.strictEqual(effectRuns, 7)
16 assert.strictEqual(layerRuns, 7)
17 assert.strictEqual(overrideRuns, 2)
18 })
19
20 it.prop("uses global defaults in plain properties", [Schema.Boolean], () => {
21 plainRuns++
22 })
23
24 it.effect.prop("uses global defaults in Effect properties", [Schema.Boolean], () =>
25 Effect.sync(() => {
26 effectRuns++
27 }))
28
29 it.prop("lets a property override the run count", [Schema.Boolean], () => {
30 overrideRuns++
31 }, { arbitrary: { runs: 2 } })
32
33 layer(Layer.empty)("layer properties", (it) => {
34 it.effect.prop("uses global defaults inside a layer", [Schema.Boolean], () =>
35 Effect.sync(() => {
36 layerRuns++
37 }))
38 })
39})