Skip to content

Instantly share code, notes, and snippets.

@gsans
Last active July 21, 2017 11:15
Show Gist options
  • Save gsans/2827a135bc84dbe766c4d04d7a2fcda5 to your computer and use it in GitHub Desktop.
Save gsans/2827a135bc84dbe766c4d04d7a2fcda5 to your computer and use it in GitHub Desktop.
capitalisePipe.spec.ts
describe('Pipe: CapitalisePipe', () => {
let pipe;
//setup
beforeEach(() => TestBed.configureTestingModule({
providers: [ CapitalisePipe ]
}));
beforeEach(inject([CapitalisePipe], p => {
pipe = p;
}));
//specs
it('should work with empty string', () => {
expect(pipe.transform('')).toEqual('');
});
it('should capitalise', () => {
expect(pipe.transform('wow')).toEqual('WOW');
});
it('should throw with invalid values', () => {
//must use arrow function for expect to capture exception
expect(()=>pipe.transform(undefined)).toThrow();
expect(()=>pipe.transform()).toThrow();
expect(()=>pipe.transform()).toThrowError('Requires a String as input');
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment