Comparing version 0.1.0-next.10 to 0.1.0-next.11
{ | ||
"name": "alge", | ||
"version": "0.1.0-next.10", | ||
"version": "0.1.0-next.11", | ||
"repository": "git@github.com:jasonkuhrt/alge.git", | ||
@@ -5,0 +5,0 @@ "author": "Jason Kuhrt", |
@@ -39,14 +39,39 @@ import { Alge } from '.' | ||
}) | ||
describe(`namespace api`, () => { | ||
it(`The name of variant is statically known and available at runtime`, () => { | ||
describe(`api`, () => { | ||
it(`.symbol contains the unique symbol for this variant`, () => { | ||
const A = Alge.create($A).variant($M, { a: z.string() }).variant($N, { a: z.string() }).done() | ||
expectType<symbol>(A.M.symbol) | ||
expect(typeof A.M.symbol).toBe(`symbol`) | ||
}) | ||
it(`.name contains the name of the variant`, () => { | ||
const A = Alge.create($A).variant($M, { a: z.string() }).variant($N, { a: z.string() }).done() | ||
expectType<$M>(A.M.name) | ||
expect(A.M.name).toBe($M) | ||
expectType<$N>(A.N.name) | ||
expect(A.N.name).toBe($N) | ||
}) | ||
it(`The tag (symbol) of variant is statically known and available at runtime`, () => { | ||
it(`.schema contains the zod schema for the variant`, () => { | ||
const A = Alge.create($A).variant($M, { a: z.string() }).variant($N, { a: z.string() }).done() | ||
expectType<symbol>(A.M.symbol) | ||
expect(typeof A.M.symbol).toBe(`symbol`) | ||
expectType<z.ZodSchema>(A.M.schema) | ||
expect(A.M.schema).toBeDefined() | ||
expect(A.M.schema.safeParse(``).success).toBe(false) | ||
expectType<z.ZodSchema>(A.N.schema) | ||
expect(A.N.schema).toBeDefined() | ||
expect(A.N.schema.safeParse(``).success).toBe(false) | ||
}) | ||
it(`.create() constructs data of that variant`, () => { | ||
const A = Alge.create($A).variant($M, { m: z.string() }).variant($N, { n: z.number() }).done() | ||
// @ts-expect-error: Invalid input | ||
A.M.create({ x: 1 }) | ||
// @ts-expect-error: Input required | ||
A.M.create() | ||
// @ts-expect-error: Input required | ||
A.M.create({ m: `m`, n: 2 }) | ||
expect(A.M.create({ m: `m` })).toEqual({ m: `m`, _tag: $M, _: { symbol: A.M.symbol } }) | ||
expect(A.N.create({ n: 1 })).toEqual({ n: 1, _tag: $N, _: { symbol: A.N.symbol } }) | ||
}) | ||
it(`.create()`, () => { | ||
@@ -53,0 +78,0 @@ const A = Alge.create($A).variant($M, { a: z.string() }).variant($N, { a: z.string() }).done() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87934
1402