diff options
| author | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-21 06:29:31 +0000 |
|---|---|---|
| committer | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-21 06:29:31 +0000 |
| commit | ee8e1a13b60a6adfdc691b2a9b57289188397641 (patch) | |
| tree | 096633208d9b8b6b59b67f4034a0cbb41e1f4c5d /node_modules/express-validator/test/formatParamOutputTest.js | |
| parent | 689df70a38ace2f88cfef6ab50f10dc546b48f00 (diff) | |
need pull
Diffstat (limited to 'node_modules/express-validator/test/formatParamOutputTest.js')
| -rw-r--r-- | node_modules/express-validator/test/formatParamOutputTest.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/node_modules/express-validator/test/formatParamOutputTest.js b/node_modules/express-validator/test/formatParamOutputTest.js new file mode 100644 index 0000000..9d67b5f --- /dev/null +++ b/node_modules/express-validator/test/formatParamOutputTest.js @@ -0,0 +1,25 @@ +var chai = require('chai'); +var expect = chai.expect; +var formatParamOutput = require('../index').utils.formatParamOutput; + +describe('#formatParamOutput()', function() { + it('should correct return formatted string if all elements in array are strings', function() { + expect(formatParamOutput(['hey', 'yo', 'hello'])).to.equal('hey.yo.hello'); + }); + + it('should return a string with integers in brackets', function() { + expect(formatParamOutput(['hey', 'yo', '0', 'hello'])).to.equal('hey.yo[0].hello'); + expect(formatParamOutput(['hey', 'yo', 0, 'hello'])).to.equal('hey.yo[0].hello'); + expect(formatParamOutput(['hey', 'yo', 0, 0, 'hello'])).to.equal('hey.yo[0][0].hello'); + expect(formatParamOutput(['hey', 'yo', 2342342, 'hello'])).to.equal('hey.yo[2342342].hello'); + expect(formatParamOutput(['hey', 'yo', '2342342', 'hello'])).to.equal('hey.yo[2342342].hello'); + expect(formatParamOutput(['hey', 'yo', '234ALPHA2342', 'hello'])).to.not.equal('hey.yo[234ALPHA2342].hello'); + expect(formatParamOutput(['hey', 'yo', 'hello', 0])).to.equal('hey.yo.hello[0]'); + expect(formatParamOutput(['hey', 'yo', 'hello', 0, 0])).to.equal('hey.yo.hello[0][0]'); + expect(formatParamOutput(['hey', 'yo', 0, 'hello', 0, 0])).to.equal('hey.yo[0].hello[0][0]'); + }); + + it('should return the original param if not an array', function() { + expect(formatParamOutput('yo')).to.equal('yo'); + }); +});
\ No newline at end of file |
