UNPKG

@eplata/utils

Version:

Modulo que contiene funciones generales para tratamiento de datos.

50 lines (36 loc) 1.55 kB
const chai = require('chai'); const proxyquire = require('proxyquire').noCallThru(); const sinon = require('sinon'); const faker = require('faker'); const chaiAsPromised = require('chai-as-promised'); chai.use(chaiAsPromised); const expect = chai.expect; describe('Utils Module::string - tryParseFloat() Unit Test', () => { describe('Case Success - Get integer value from string value.', () => { const strMock = '123456.00'; const tryParseFloatFunction = require('../../src/string/try-parse-float'); const result = tryParseFloatFunction(strMock); it(`Should return a integer.`, () => { expect(result).to.be.a('number'); }); }); describe('Case Success - Get string value when cant parse string value', () => { const strMock = '123456.00abc'; const tryParseFloatFunction = require('../../src/string/try-parse-float'); const result = tryParseFloatFunction(strMock); it(`Should return a integer.`, () => { expect(result).to.be.a('string'); }); }); describe('Case Exception - Get exception when cant parse string value and strict flag is true', () => { const strMock = '123456.00abc'; const tryParseFloatFunction = require('../../src/string/try-parse-float'); try { const result = tryParseFloatFunction(strMock, true); } catch (error) { it(`Should thow exception.`, () => { expect(error).to.be.a('error'); }); } }); });