import { Data, Schema, Option } from 'effect';
import { AssertionError } from 'node:assert'
export const UserData = Schema.Struct({
apiKey: Schema.Option(Schema.String),
baseURL: Schema.Option(Schema.String),
}).annotations({
identifier: 'UserData',
});
if (import.meta.vitest) {
const { it } = await import('@effect/vitest');
const { assertEquals, throws } = await import('@effect/vitest/utils');
it('`Schema.Struct.make` is not compatible with `Data.struct`', () => {
const actual = UserData.make({
apiKey: Option.some('api_key'),
baseURL: Option.none(),
});
const expected = Data.struct({
apiKey: Option.some('api_key'),
baseURL: Option.none(),
});
throws(
// AssertionError: `Values have same structure but are not reference-equal`
() => assertEquals(actual, expected),
new AssertionError({
actual: actual,
expected: expected,
operator: 'deepStrictEqual',
}),
);
assertEquals(Data.struct(actual), expected);
})
}
import { Data, Schema, Option } from 'effect';
import { AssertionError } from 'node:assert'
export const UserData = Schema.Struct({
apiKey: Schema.Option(Schema.String),
baseURL: Schema.Option(Schema.String),
}).annotations({
identifier: 'UserData',
});
if (import.meta.vitest) {
const { it } = await import('@effect/vitest');
const { assertEquals, throws } = await import('@effect/vitest/utils');
it('`Schema.Struct.make` is not compatible with `Data.struct`', () => {
const actual = UserData.make({
apiKey: Option.some('api_key'),
baseURL: Option.none(),
});
const expected = Data.struct({
apiKey: Option.some('api_key'),
baseURL: Option.none(),
});
throws(
// AssertionError: `Values have same structure but are not reference-equal`
() => assertEquals(actual, expected),
new AssertionError({
actual: actual,
expected: expected,
operator: 'deepStrictEqual',
}),
);
assertEquals(Data.struct(actual), expected);
})
}