Last active
July 21, 2017 11:15
-
-
Save gsans/2827a135bc84dbe766c4d04d7a2fcda5 to your computer and use it in GitHub Desktop.
capitalisePipe.spec.ts
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
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