Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
JSONSchema: use JsonNumber in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Oct 20, 2023
1 parent a9976f3 commit 44635ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-trains-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/schema": patch
---

expose JSON Schema compiler
15 changes: 7 additions & 8 deletions test/JSONSchema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ describe("JSONSchema", () => {
})

it("record(${string}-${string}, number)", () => {
const schema = S.record(S.templateLiteral(S.string, S.literal("-"), S.string), S.number)
const schema = S.record(S.templateLiteral(S.string, S.literal("-"), S.string), S.JsonNumber)
const jsonSchema = JSONSchema.to(schema)
expect(jsonSchema).toStrictEqual({
"$schema": "http://json-schema.org/draft-07/schema#",
Expand All @@ -633,8 +633,8 @@ describe("JSONSchema", () => {
"patternProperties": {
"^.*-.*$": {
"type": "number",
"description": "a number",
"title": "number"
"description": "a JSON number",
"title": "JsonNumber"
}
}
})
Expand Down Expand Up @@ -810,7 +810,6 @@ describe("JSONSchema", () => {
expect(validate("a12")).toEqual(true)
expect(validate("a")).toEqual(false)
expect(validate("aa")).toEqual(false)
propertyTo(schema)
})

describe("Lazy", () => {
Expand Down Expand Up @@ -897,7 +896,7 @@ describe("JSONSchema", () => {
const Expression: S.Schema<Expression> = S.lazy(() =>
S.struct({
type: S.literal("expression"),
value: S.union(S.number, Operation)
value: S.union(S.JsonNumber, Operation)
})
).pipe(S.identifier("Expression"))

Expand Down Expand Up @@ -967,8 +966,8 @@ describe("JSONSchema", () => {
},
{
"type": "number",
"description": "a number",
"title": "number"
"description": "a JSON number",
"title": "JsonNumber"
}
]
}
Expand Down Expand Up @@ -1030,7 +1029,7 @@ describe("JSONSchema", () => {
title: "foo title",
examples: ["foo example"]
}),
bar: S.propertySignature(S.number, {
bar: S.propertySignature(S.JsonNumber, {
description: "bar description",
title: "bar title",
examples: ["bar example"]
Expand Down

0 comments on commit 44635ad

Please sign in to comment.