this:
it('should allow optional struct with default value', async () => {
const FirestoreMock = Layer.mock(FirestoreService, {
get: (path) => {
if (path === 'm/test') {
return Effect.succeed(Option.some([{ id: 'test', path }, { id: 'test' }]))
}
return Effect.succeed(Option.none())
}
})
const structWithDefault = Schema.Struct({
a: Schema.optionalWith(Schema.String, { default: () => 'a' })
})
const id = Schema.String
class M extends Model.Class<M>('M')({
id: Model.Generated(id),
...structWithDefault.fields
}) {
static idField = 'id' as const
}
const MRepo = Model.makeRepository(M, {
collectionPath: 'm',
idField: M.idField,
spanPrefix: 'm.repository',
})
const getM = Effect.gen(function* () {
const m = yield* MRepo
return yield* m.getById('test').pipe(Effect.map(Option.getOrUndefined))
})
const program = getM.pipe(
Effect.provide(FirestoreMock)
)
const result = await Effect.runPromise(program)
expect(result).toBeDefined()
expect(result?.a).toBe('a')
})
})
produce :
(FiberFailure) Error: Unsupported schema
schema (Transformation): ({ readonly a?: string | undefined } <-> { readonly a: string })
with latest effect and effect-firebase versions.
this:
produce :
with latest effect and effect-firebase versions.