How to use @microsoft/fast-permutator - 9 common examples

To help you get started, we’ve selected a few @microsoft/fast-permutator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / fast-dna / packages / fast-form-generator-react / app / components / checkbox / checkbox.spec.tsx View on Github external
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);
});
github microsoft / fast-dna / packages / fast-form-generator-react / app / components / attribute-assignment / attribute-assignment.spec.tsx View on Github external
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);
});
github microsoft / fast-dna / packages / fast-form-generator-react / app / components / number-field / number-field.spec.tsx View on Github external
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);
});
github microsoft / fast-dna / packages / fast-form-generator-react / app / components / text-field / text-field.spec.tsx View on Github external
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);
});
github microsoft / fast-dna / packages / fast-form-generator-react / app / components / one-of / one-of.spec.tsx View on Github external
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);
});
github microsoft / fast-dna / packages / fast-form-generator-react / src / form / form-section.utilities.tsx View on Github external
function getArrayExample(schemaSection: any): any[] {
    const example: any = getExample(schemaSection.items);

    if (schemaSection.minItems) {
        return new Array(schemaSection.length - 1).fill(example);
    }

    return [example];
}
github microsoft / fast-dna / packages / fast-form-generator-react / src / form / form-section.utilities.tsx View on Github external
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);
}
github microsoft / fast-dna / packages / fast-form-generator-react / app / index.tsx View on Github external
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,
        });
    };
github microsoft / fast-dna / packages / fast-form-generator-react / app / components / objects / objects.spec.tsx View on Github external
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);
});

@microsoft/fast-permutator

Creates all possible permutations of a component based on its JSON Schema.

MIT
Latest version published 5 years ago

Package Health Score

73 / 100
Full package analysis

Popular @microsoft/fast-permutator functions

Similar packages