ng2-pipes
Version:
Useful angular2 pipes
29 lines (22 loc) • 748 B
text/typescript
import {RepeatPipe} from "./repeat";
describe('RepeatPipe Tests', () => {
let pipe:RepeatPipe;
beforeEach(() => {
pipe = new RepeatPipe();
});
it('Should repeat string', () => {
let result = pipe.transform('foo', 3);
expect(result).toEqual('foofoofoo');
});
it('Should repeat string with separator', () => {
let result = pipe.transform('foo', 3, '-');
expect(result).toEqual('foo-foo-foo');
});
it('Should return the same value when there are no arguments', () => {
let result = pipe.transform('foo');
expect(result).toEqual('foo');
});
it('Should throw range exception if times count is below zero', () => {
expect(() => { pipe.transform('foo', -1) }).toThrow(new RangeError());
});
});