| Total Complexity | 6 |
| Complexity/F | 1 |
| Lines of Code | 31 |
| Function Count | 6 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | 'use strict'; |
||
| 2 | const expect = require('chai').expect; |
||
| 3 | const autoCast = require('../../src/lib/utils').autoCast; |
||
| 4 | |||
| 5 | |||
| 6 | describe('utils', function(){ |
||
| 7 | |||
| 8 | describe('autoCast', function(){ |
||
| 9 | it('should cast to an integer', function(){ |
||
| 10 | expect(autoCast("42")).to.equal(42); |
||
| 11 | }) |
||
| 12 | |||
| 13 | it('should cast to a float', function(){ |
||
| 14 | expect(autoCast("42.0")).to.equal(42.0); |
||
| 15 | expect(autoCast("42.42")).to.equal(42.42); |
||
| 16 | }) |
||
| 17 | |||
| 18 | it('should cast to a boolean', function(){ |
||
| 19 | expect(autoCast("true")).to.be.true; |
||
|
|
|||
| 20 | expect(autoCast("True")).to.be.true; |
||
| 21 | |||
| 22 | expect(autoCast("false")).to.be.false; |
||
| 23 | expect(autoCast("False")).to.be.false; |
||
| 24 | }) |
||
| 25 | |||
| 26 | it('should return a string if no other type matches', function(){ |
||
| 27 | expect(autoCast('icls')).to.equal('icls'); |
||
| 28 | }) |
||
| 29 | }); |
||
| 30 | |||
| 31 | }); |
||
| 32 |