Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as React from "react";
import { generateSnapshots } from "@microsoft/fast-jest-snapshots-react";
import { SnapshotTestSuite } from "@microsoft/fast-jest-snapshots-react";
import { getExample } from "@microsoft/fast-permutator";
import Form, { FormProps } from "../../../src/form";
import * as checkboxSchema from "./checkbox.schema.json";
const name: string = "checkbox";
const exampleData: FormProps = {
schema: checkboxSchema,
data: getExample(checkboxSchema),
/* tslint:disable-next-line */
onChange: (data: any): void => {},
};
const examples: SnapshotTestSuite = {
name,
component: Form,
data: [exampleData],
};
describe(name, () => {
generateSnapshots(examples);
});
import * as React from "react";
import { generateSnapshots } from "@microsoft/fast-jest-snapshots-react";
import { SnapshotTestSuite } from "@microsoft/fast-jest-snapshots-react";
import { getExample } from "@microsoft/fast-permutator";
import Form, { FormProps } from "../../../src/form";
import config from "./attribute-assignment.config";
import * as attributeAssignmentSchema from "./attribute-assignment.schema.json";
const name: string = "attribute-assignment";
const exampleData: FormProps = {
schema: attributeAssignmentSchema,
data: getExample(attributeAssignmentSchema),
/* tslint:disable-next-line */
onChange: (data: any): void => {},
attributeSettingsMappingToPropertyNames: config,
};
const examples: SnapshotTestSuite = {
name,
component: Form,
data: [exampleData],
};
describe(name, () => {
generateSnapshots(examples);
});
import * as React from "react";
import { generateSnapshots } from "@microsoft/fast-jest-snapshots-react";
import { SnapshotTestSuite } from "@microsoft/fast-jest-snapshots-react";
import { getExample } from "@microsoft/fast-permutator";
import Form, { FormProps } from "../../../src/form";
import * as numberFieldSchema from "./number-field.schema.json";
const name: string = "number-field";
const exampleData: FormProps = {
schema: numberFieldSchema,
data: getExample(numberFieldSchema),
/* tslint:disable-next-line */
onChange: (data: any): void => {},
};
const examples: SnapshotTestSuite = {
name,
component: Form,
data: [exampleData],
};
describe(name, () => {
generateSnapshots(examples);
});
import * as React from "react";
import { generateSnapshots } from "@microsoft/fast-jest-snapshots-react";
import { SnapshotTestSuite } from "@microsoft/fast-jest-snapshots-react";
import { getExample } from "@microsoft/fast-permutator";
import Form, { FormProps } from "../../../src/form";
import * as textFieldSchema from "./text-field.schema.json";
const name: string = "text-field";
const exampleData: FormProps = {
schema: textFieldSchema,
data: getExample(textFieldSchema),
/* tslint:disable-next-line */
onChange: (data: any): void => {},
};
const examples: SnapshotTestSuite = {
name,
component: Form,
data: [exampleData],
};
describe(name, () => {
generateSnapshots(examples);
});
import * as React from "react";
import { generateSnapshots } from "@microsoft/fast-jest-snapshots-react";
import { SnapshotTestSuite } from "@microsoft/fast-jest-snapshots-react";
import { getExample } from "@microsoft/fast-permutator";
import Form, { FormProps } from "../../../src/form";
import * as oneOfSchema from "./one-of.schema.json";
const name: string = "one-of";
const exampleData: FormProps = {
schema: oneOfSchema,
data: getExample(oneOfSchema),
/* tslint:disable-next-line */
onChange: (data: any): void => {},
};
const examples: SnapshotTestSuite = {
name,
component: Form,
data: [exampleData],
};
describe(name, () => {
generateSnapshots(examples);
});
function getArrayExample(schemaSection: any): any[] {
const example: any = getExample(schemaSection.items);
if (schemaSection.minItems) {
return new Array(schemaSection.length - 1).fill(example);
}
return [example];
}
if (schemaSection.oneOf) {
schemaSection = schemaSection.oneOf[0];
}
if (schemaSection.anyOf) {
schemaSection = schemaSection.anyOf[0];
}
schemaSection.type = checkIsObjectAndSetType(schemaSection);
if (schemaSection.items) {
return getArrayExample(schemaSection);
}
return getExample(schemaSection);
}
private handleComponentUpdate = (e: React.ChangeEvent): void => {
const exampleData: any = getExample(testConfigs[e.target.value].schema);
this.setState({
schema: testConfigs[e.target.value].schema,
config: testConfigs[e.target.value].config,
data: exampleData,
orderByPropertyNames: testConfigs[e.target.value].weight,
attributeAssignment: testConfigs[e.target.value].attributeAssignment,
});
};
import * as React from "react";
import { generateSnapshots } from "@microsoft/fast-jest-snapshots-react";
import { SnapshotTestSuite } from "@microsoft/fast-jest-snapshots-react";
import { getExample } from "@microsoft/fast-permutator";
import Form, { FormProps } from "../../../src/form";
import * as objectsSchema from "./objects.schema.json";
import { noop } from "lodash-es";
const name: string = "objects";
const exampleData: FormProps = {
schema: objectsSchema,
data: getExample(objectsSchema),
onChange: noop,
};
const examples: SnapshotTestSuite = {
name,
component: Form,
data: [exampleData],
};
describe(name, () => {
generateSnapshots(examples);
});