Created
November 17, 2017 23:21
-
-
Save sentientmonkey/f444453143878a52b65617a0a541271e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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