Last active
March 12, 2017 05:06
-
-
Save garbles/356c15539f202e48f1c6cd5586b022d1 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 type {Person} from './types'; | |
export default function setName(person: Person, name: string): Person { | |
return { | |
...person, | |
name | |
}; | |
} |
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 setName from './setName'; | |
require('jasmine-check').install(); | |
describe('setName', () => { | |
check.it('sets a new name', [setName.asGenerator()], (args) => { | |
const [person, newName] = args; | |
const next = setName(...args); | |
expect(next.name).toEqual(newName); | |
expect(person).not.toBe(next); | |
}); | |
}); |
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 type Person = { | |
name: string, | |
age: number | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment