Created
September 8, 2017 19:34
-
-
Save kylewhitaker/5fe008c6bf4ab666dc2cfa49a932ff93 to your computer and use it in GitHub Desktop.
Step #1 to writing a great unit test file is scaffolding!
This file contains 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
describe('SomeComponent:', () => { | |
describe('someMethod', () => { | |
describe('true', () => { | |
it('should call depOne.doSomething', () => { | |
}); | |
it('should return string \'eggs for breakfast\'', () => { | |
}); | |
}); | |
describe('false', () => { | |
it('should call depTwo.doSomethingElse', () => { | |
}); | |
it('should return string \'steak for dinner\'', () => { | |
}); | |
}); | |
}); | |
describe('returnSomeObservable', () => { | |
it('should return a string Observable of \'test\'', () => { | |
}); | |
}); | |
describe('subscribeAndDoSomething', () => { | |
it('should call depThree.capitalize on the value \'jabroni\' emitted', () => { | |
}); | |
}); | |
}); |
This file contains 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 { Observable } from 'rxjs'; | |
import { DepOne, DepTwo, DepThree } from './dependencies'; | |
export class SomeComponent { | |
constructor( | |
private depOne: DepOne, | |
private depTwo: DepTwo, | |
private depThree: DepThree | |
) { } | |
someMethod(someCondition: boolean): string { | |
if (someCondition) { | |
this.depOne.doSomething(); | |
return 'eggs for breakfast'; | |
} else { | |
this.depTwo.doSomethingElse(); | |
return 'steak for dinner'; | |
} | |
} | |
returnSomeObservable(): Observable<string> { | |
return Observable.of('test'); | |
} | |
subscribeAndDoSomething(): void { | |
Observable.of('jabroni').subscribe((value) => { | |
this.depThree.capitalize(value); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment