UNPKG

@websolute/faker.ts

Version:

Easy to Use, Powered by Decorators, Faker.js TypeScript Wrapper

62 lines (61 loc) 1.65 kB
import 'reflect-metadata'; import { Callback, Class, EnumObject, ExactValue, MultiClass } from '../types/fixture-options.type'; export declare const FIXTURE_DECORATOR_NAME = "Fixture"; /** * Using undefined (or nothing actually) will infer the value from the property type. * The types can be either 'string', 'number' or a 'boolean' * * @constructor */ export declare function Fixture(): PropertyDecorator; /** * Will invoke the callback and generate a value from 'faker' instance * * @example * Fixture(faker => faker.internet.email()) * * @param callback * @constructor */ export declare function Fixture(callback: Callback): PropertyDecorator; /** * Generate the exact given value * * @example * Fixture(123) * Fixture('Johnny') * Fixture(true) * * @param value * @constructor */ export declare function Fixture(value: ExactValue): PropertyDecorator; /** * Generate an object matching to the given class (assuming the class is decorated with Fixture) * * @example * class Dog { ... } * Fixture(Dog) * * @param value * @constructor */ export declare function Fixture(value: Class): PropertyDecorator; /** * Generate a random value from the given enum * * @example * enum Feeling { Happy, Sad, Numb } * Fixture(Feeling) * * @param options: { enum: object } * @constructor */ export declare function Fixture(options: EnumObject): PropertyDecorator; /** * Generate multiple objects matching the given class (assuming the class is decorated with Fixture) * * @param options: { type: ClassType; count: number } * @constructor */ export declare function Fixture(options: MultiClass): PropertyDecorator;