Skip to content

Commit

Permalink
Renames fields-to-jsonschema file to indicate it only contains snapsh…
Browse files Browse the repository at this point in the history
…ot tests. generates snapshots
  • Loading branch information
nick-Ag committed Dec 2, 2024
1 parent e73ec64 commit f8a0558
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`conditionally required field schema generation should generate a schema when one field depends on another 1`] = `
Object {
"$schema": "http://json-schema.org/schema#",
"additionalProperties": false,
"allOf": Array [
Object {
"if": Object {
"properties": Object {
"a": Object {
"const": "a_value",
},
},
},
"then": Object {
"required": Array [
"b",
],
},
},
],
"properties": Object {
"a": Object {
"default": undefined,
"description": "a",
"format": undefined,
"title": "a",
"type": "string",
},
"b": Object {
"default": undefined,
"description": "b",
"format": undefined,
"title": "b",
"type": "string",
},
},
"required": Array [
"a",
],
"type": "object",
}
`;

exports[`conditionally required field schema generation should generate a schema when one field depends on multiple other fields 1`] = `
Object {
"$schema": "http://json-schema.org/schema#",
"additionalProperties": false,
"allOf": Array [
Object {
"if": Object {
"allOf": Array [
Object {
"properties": Object {
"a": Object {
"const": "a_value",
},
},
"required": Array [
"a",
],
},
Object {
"properties": Object {
"b": Object {
"const": "b_value",
},
},
"required": Array [
"b",
],
},
],
},
"then": Object {
"required": Array [
"c",
],
},
},
],
"properties": Object {
"a": Object {
"default": undefined,
"description": "a",
"format": undefined,
"title": "a",
"type": "string",
},
"b": Object {
"default": undefined,
"description": "b",
"format": undefined,
"title": "b",
"type": "string",
},
"c": Object {
"default": undefined,
"description": "c",
"format": undefined,
"title": "c",
"type": "string",
},
},
"required": Array [
"a",
],
"type": "object",
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,7 @@ describe('conditionally required field schema generation', () => {
}

const schema = fieldsToJsonSchema(mockActionFields)

console.log('schema:', schema)
/** expecting an object with:
* required: [ 'a' ],
if: {
properties: {"a": {"const": "a_value"}}
},
then: { "required": ["b"] }
*/
expect(schema).toMatchInlineSnapshot(``)
expect(schema).toMatchSnapshot()
})

it('should generate a schema when one field depends on multiple other fields', async () => {
Expand Down Expand Up @@ -61,15 +52,7 @@ describe('conditionally required field schema generation', () => {
}

const schema = fieldsToJsonSchema(mockActionFields)

console.log('schema:', schema)
/** expecting an object with:
if: {
properties: { a: { const: 'a_value' }, b: { const: 'b_value' } }
},
then: { required: [ 'c' ] }
*/
expect(schema).toMatchInlineSnapshot(``)
expect(schema).toMatchSnapshot()
})

it('should generate a schema when multiple fields depend on one field', async () => {})
Expand Down

0 comments on commit f8a0558

Please sign in to comment.