|
| 1 | +/// <reference path="../../../typings/globals/jest/index.d.ts" /> |
| 2 | + |
| 3 | +importparseParamsfrom'./parse-params'; |
| 4 | + |
| 5 | +describe('parseBreaks',function(){ |
| 6 | + |
| 7 | +describe('getParams',function(){ |
| 8 | +it('should return the same string in an array if only one param',function(){ |
| 9 | +letparams='first'; |
| 10 | +letparser=newparseParams(); |
| 11 | +letbreaks=parser.getParams(params); |
| 12 | +expect(breaks).toEqual(['first']); |
| 13 | +}); |
| 14 | + |
| 15 | +it('should return params in a simple string',function(){ |
| 16 | +letparams='first, second, third'; |
| 17 | +letparser=newparseParams(); |
| 18 | +letbreaks=parser.getParams(params); |
| 19 | +expect(breaks).toEqual(['first','second','third']); |
| 20 | +}); |
| 21 | + |
| 22 | +it('should ignore breaks within an object',function(){ |
| 23 | +letparams='{ a: 1, b: 2 }, second, third'; |
| 24 | +letparser=newparseParams(); |
| 25 | +letbreaks=parser.getParams(params); |
| 26 | +expect(breaks).toEqual(['{ a: 1, b: 2 }','second','third']); |
| 27 | +}); |
| 28 | + |
| 29 | +it('should ignore breaks within an array',function(){ |
| 30 | +letparams='[ a: 1, b: 2 ], second, third'; |
| 31 | +letparser=newparseParams(); |
| 32 | +letbreaks=parser.getParams(params); |
| 33 | +expect(breaks).toEqual(['[ a: 1, b: 2 ]','second','third']); |
| 34 | +}); |
| 35 | + |
| 36 | +it('should ignore breaks within brackets',function(){ |
| 37 | +letparams='function (a, b) {}, second, third'; |
| 38 | +letparser=newparseParams(); |
| 39 | +letbreaks=parser.getParams(params); |
| 40 | +expect(breaks).toEqual(['function (a, b) {}','second','third']); |
| 41 | +}); |
| 42 | +}); |
| 43 | + |
| 44 | +}); |