|
| 1 | +// import assert from 'assert' |
| 2 | +import path from 'path' |
| 3 | +import { assert } from 'chai' |
| 4 | +import configuration from '../setup/configuration' |
| 5 | +import { parseKeyValuePairSeparatedBySymbolConcatenatedString, parseKeyValuePairSeparatedBySymbolFromArray, combineKeyValueObjectIntoString } from '../source/parse.js' |
| 6 | +const assetFolder = path.join(configuration.directory.application.containerAbsolutePath, 'test/asset') |
| 7 | + |
| 8 | +describe('function parseKeyValuePairSeparatedBySymbolConcatenatedString: ', function() { |
| 9 | + describe('string input containing key-value pairs', function() { |
| 10 | + it('Should parse/detect key value pairs', function() { |
| 11 | + let parsed = parseKeyValuePairSeparatedBySymbolConcatenatedString({ string: 'x=1 y=2 z t=3' }), |
| 12 | + expected = { x: '1', y: '2', t: '3' } |
| 13 | + assert.deepEqual(parsed, expected) |
| 14 | + }) |
| 15 | + }) |
| 16 | +}) |
| 17 | + |
| 18 | +describe('function parseKeyValuePairSeparatedBySymbolFromArray: ', function() { |
| 19 | + describe('array input containing key-value pairs', function() { |
| 20 | + it('Should parse/detect key value pairs separated by a specific symbol', function() { |
| 21 | + let parsed = parseKeyValuePairSeparatedBySymbolFromArray({ array: [ 'x_1', 'y_2', 't_3' ], separatingSymbol: '_' }), |
| 22 | + expected = { x: '1', y: '2', t: '3' } |
| 23 | + assert.deepEqual(parsed, expected) |
| 24 | + }) |
| 25 | + }) |
| 26 | +}) |
| 27 | + |
| 28 | +describe('function combineKeyValueObjectIntoString: ', function() { |
| 29 | + describe('Convert object to string with key-value separated structure', function() { |
| 30 | + it('Should encode object into string', function() { |
| 31 | + let actual = combineKeyValueObjectIntoString({ object: { x: '1', y: '2', t: '3' }, separatingSymbol: '_' }), |
| 32 | + expected = 'x_1 y_2 t_3' |
| 33 | + assert.equal(actual, expected) |
| 34 | + }) |
| 35 | + }) |
| 36 | +}) |
| 37 | + |
| 38 | + |
0 commit comments