Skip to content

Commit

Permalink
Fix strict type warning for object tests
Browse files Browse the repository at this point in the history
  • Loading branch information
newt10 committed Sep 9, 2021
1 parent 88ed23a commit 4b97721
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 15 deletions.
48 changes: 38 additions & 10 deletions packages/core/test/anyOf_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ describe("anyOf", () => {

it("should render a select element if the anyOf keyword is present", () => {
const schema = {
type: "object",
anyOf: [
{
type: "object",
properties: {
foo: { type: "string" },
},
},
{
type: "object",
properties: {
bar: { type: "string" },
},
Expand Down Expand Up @@ -132,14 +133,15 @@ describe("anyOf", () => {
it("should assign a default value and set defaults on option change with 'type': 'object' missing", () => {
const { node, onChange } = createFormComponent({
schema: {
type: "object",
anyOf: [
{
type: "object",
properties: {
foo: { type: "string", default: "defaultfoo" },
},
},
{
type: "object",
properties: {
foo: { type: "string", default: "defaultbar" },
},
Expand All @@ -165,14 +167,15 @@ describe("anyOf", () => {

it("should render a custom widget", () => {
const schema = {
type: "object",
anyOf: [
{
type: "object",
properties: {
foo: { type: "string" },
},
},
{
type: "object",
properties: {
bar: { type: "string" },
},
Expand All @@ -195,14 +198,15 @@ describe("anyOf", () => {

it("should change the rendered form when the select value is changed", () => {
const schema = {
type: "object",
anyOf: [
{
type: "object",
properties: {
foo: { type: "string" },
},
},
{
type: "object",
properties: {
bar: { type: "string" },
},
Expand All @@ -229,14 +233,15 @@ describe("anyOf", () => {

it("should handle change events", () => {
const schema = {
type: "object",
anyOf: [
{
type: "object",
properties: {
foo: { type: "string" },
},
},
{
type: "object",
properties: {
bar: { type: "string" },
},
Expand Down Expand Up @@ -265,11 +270,13 @@ describe("anyOf", () => {
},
anyOf: [
{
type: "object",
properties: {
foo: { type: "string" },
},
},
{
type: "object",
properties: {
bar: { type: "string" },
},
Expand Down Expand Up @@ -451,9 +458,9 @@ describe("anyOf", () => {

it("should not change the selected option when entering values", () => {
const schema = {
type: "object",
anyOf: [
{
type: "object",
title: "First method of identification",
properties: {
firstName: {
Expand All @@ -465,6 +472,7 @@ describe("anyOf", () => {
},
},
{
type: "object",
title: "Second method of identification",
properties: {
idCode: {
Expand Down Expand Up @@ -498,9 +506,9 @@ describe("anyOf", () => {

it("should not change the selected option when entering values and the subschema uses `anyOf`", () => {
const schema = {
type: "object",
anyOf: [
{
type: "object",
title: "First method of identification",
properties: {
firstName: {
Expand All @@ -512,6 +520,7 @@ describe("anyOf", () => {
},
},
{
type: "object",
title: "Second method of identification",
properties: {
idCode: {
Expand All @@ -520,13 +529,15 @@ describe("anyOf", () => {
},
anyOf: [
{
type: "object",
properties: {
foo: {
type: "string",
},
},
},
{
type: "object",
properties: {
bar: {
type: "string",
Expand Down Expand Up @@ -561,9 +572,9 @@ describe("anyOf", () => {

it("should not change the selected option when entering values and the subschema uses `allOf`", () => {
const schema = {
type: "object",
anyOf: [
{
type: "object",
title: "First method of identification",
properties: {
firstName: {
Expand All @@ -575,6 +586,7 @@ describe("anyOf", () => {
},
},
{
type: "object",
title: "Second method of identification",
properties: {
idCode: {
Expand All @@ -583,13 +595,15 @@ describe("anyOf", () => {
},
allOf: [
{
type: "object",
properties: {
foo: {
type: "string",
},
},
},
{
type: "object",
properties: {
bar: {
type: "string",
Expand Down Expand Up @@ -624,21 +638,23 @@ describe("anyOf", () => {

it("should not mutate a schema that contains nested anyOf and allOf", () => {
const schema = {
type: "object",
anyOf: [
{
type: "object",
properties: {
foo: { type: "string" },
},
allOf: [
{
type: "object",
properties: {
baz: { type: "string" },
},
},
],
anyOf: [
{
type: "object",
properties: {
buzz: { type: "string" },
},
Expand All @@ -653,21 +669,23 @@ describe("anyOf", () => {
});

expect(schema).to.eql({
type: "object",
anyOf: [
{
type: "object",
properties: {
foo: { type: "string" },
},
allOf: [
{
type: "object",
properties: {
baz: { type: "string" },
},
},
],
anyOf: [
{
type: "object",
properties: {
buzz: { type: "string" },
},
Expand Down Expand Up @@ -726,6 +744,7 @@ describe("anyOf", () => {

it("should collect schema from $ref even when ref is within properties", () => {
const schema = {
type: "object",
properties: {
address: {
title: "Address",
Expand Down Expand Up @@ -781,13 +800,15 @@ describe("anyOf", () => {
type: "object",
anyOf: [
{
type: "object",
properties: {
foo: {
type: "string",
},
},
},
{
type: "object",
properties: {
bar: {
type: "string",
Expand Down Expand Up @@ -823,13 +844,15 @@ describe("anyOf", () => {
type: "object",
anyOf: [
{
type: "object",
properties: {
foo: {
type: "string",
},
},
},
{
type: "object",
properties: {
bar: {
type: "string",
Expand Down Expand Up @@ -876,13 +899,15 @@ describe("anyOf", () => {
type: "object",
anyOf: [
{
type: "object",
properties: {
foo: {
type: "string",
},
},
},
{
type: "object",
properties: {
bar: {
type: "string",
Expand Down Expand Up @@ -918,12 +943,14 @@ describe("anyOf", () => {
type: "object",
anyOf: [
{
type: "object",
title: "Foo",
properties: {
foo: { type: "string" },
},
},
{
type: "object",
properties: {
bar: { type: "string" },
},
Expand All @@ -935,6 +962,7 @@ describe("anyOf", () => {
definitions: {
baz: {
title: "Baz",
type: "object",
properties: {
baz: { type: "string" },
},
Expand Down
Loading

0 comments on commit 4b97721

Please sign in to comment.