model-builder-ts
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

model-builder-ts

A Node.js module that create models for testing

Installation

npm install model-builder-ts --save-dev

Usage

import {ModelBuilder} from 'model-builder-ts';
 
interface Person {
  name: string;
  age: number;
  dob: Date;
  married: boolean;
  email?: string;
}
 
class PersonModelBuilder extends ModelBuilder<Person> {
  public min(): Person {
    return {
      age: 20,
      dob: new Date(0),
      email: '7fate@web.de',
      married: true,
      name: 'Mario',
    } as Person;
  }
}
 
test('Person ModelBuilder#min', () => {
  const sut = new PersonModelBuilder();
 
  const person = sut.min();
 
  expect(person.name).toEqual('Mario');
  expect(person.age).toEqual(20);
  expect(person.dob).toEqual(new Date(0));
  expect(person.married).toEqual(true);
});

License

MIT (unless noted otherwise)

Readme

Keywords

Package Sidebar

Install

npm i model-builder-ts

Weekly Downloads

0

Version

2.0.0

License

MIT

Unpacked Size

3.07 kB

Total Files

4

Last publish

Collaborators

  • microtema