From d077d8267d6989b2c5083809e1de2f3ed91f35cf Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sat, 12 Dec 2015 18:30:59 +0200 Subject: [PATCH] helpers testsuite --- tests/unit/helpers.spec.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/unit/helpers.spec.js diff --git a/tests/unit/helpers.spec.js b/tests/unit/helpers.spec.js new file mode 100644 index 00000000..01399beb --- /dev/null +++ b/tests/unit/helpers.spec.js @@ -0,0 +1,31 @@ +'use strict'; + +import {statusCodeType} from 'lib/utils/helpers'; +describe('statusCodeType', () => { + it('Should return info for status codes within 100 and 200', ()=> { + statusCodeType(100).should.be.equal('info'); + statusCodeType(150).should.be.equal('info'); + statusCodeType(199).should.be.equal('info'); + }); + + it('Should return success for status codes within 200 and 300', ()=> { + statusCodeType(200).should.be.equal('success'); + statusCodeType(250).should.be.equal('success'); + statusCodeType(299).should.be.equal('success'); + }); + it('Should return redirect for status codes within 300 and 400', ()=> { + statusCodeType(300).should.be.equal('redirect'); + statusCodeType(350).should.be.equal('redirect'); + statusCodeType(399).should.be.equal('redirect'); + }); + it('Should return error for status codes above 400', ()=> { + statusCodeType(400).should.be.equal('error'); + statusCodeType(500).should.be.equal('error'); + statusCodeType(599).should.be.equal('error'); + }); + + it('Should throw for incorrect HTTP code', ()=> { + (() => statusCodeType(99)).should.throw('invalid HTTP code'); + (() => statusCodeType(600)).should.throw('invalid HTTP code'); + }); +});