model-builder-ts
v2.0.0
Published
Reduce boiler plate on testing
Downloads
5
Readme
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: '[email protected]',
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)