Skip to content

Instantly share code, notes, and snippets.

@sentientmonkey
Created November 17, 2017 23:21
Show Gist options
  • Save sentientmonkey/f444453143878a52b65617a0a541271e to your computer and use it in GitHub Desktop.
Save sentientmonkey/f444453143878a52b65617a0a541271e to your computer and use it in GitHub Desktop.
import Person from "./person";
describe('a person', () => {
it('should create default', () => {
let person = new Person();
let defaultPerson = new Person({name: "default", address: "default", age: 0});
expect(person).toEqual(defaultPerson);
});
it('should create with parameters', () => {
let person = new Person({name: "foo", address: "bar", age: 20});
let defaultPerson = new Person({name: "foo", address: "bar", age: 20});
expect(person).toEqual(defaultPerson);
});
});
export default class Person {
public name: string = "default"
public address: string = "default"
public age: number = 0;
public constructor(init:Partial<Person> = {} as Partial<Person>) {
this.name = init.name || this.name;
this.address = init.address || this.address;
this.age = init.age || this.age;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment