import * as sinon from 'sinon';
import { expect } from 'chai';
import { ArgumentMetadata } from '../../interfaces';
import { ParseIntPipe } from './../../pipes/parse-int.pipe';

describe('ParseIntPipe', () => {
  let target: ParseIntPipe;
  beforeEach(() => {
    target = new ParseIntPipe();
  });
  describe('transform', () => {
    describe('when validation passes', () => {
      it('should return number', async () => {
        const num = '3';
        expect(await target.transform(num, {} as any)).to.equal(
          parseInt(num, 10),
        );
      });
    });
    describe('when validation fails', () => {
      it('should throw an error', async () => {
        return expect(target.transform('123abc', {} as any)).to.be.rejected;
      });
    });
  });
});
