Skip to content

Instantly share code, notes, and snippets.

@AlexLakatos
Forked from gsans/capitalisePipe.spec.ts
Created July 21, 2017 11:13
Show Gist options
  • Select an option

  • Save AlexLakatos/5c69ff07710ca5b2776d9ad491332c65 to your computer and use it in GitHub Desktop.

Select an option

Save AlexLakatos/5c69ff07710ca5b2776d9ad491332c65 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