]);
});
- it('tests _convertValue', () => {
+ describe('tests _convertValue', () => {
const v = (value) => ({ key: 'sth', value: value });
- expect(component._convertValue(v('something'))).toEqual(v('something'));
- expect(component._convertValue(v([1, 2, 3]))).toEqual(v('1, 2, 3'));
- expect(component._convertValue(v({ sth: 'something' }))).toBe(undefined);
- component.renderObjects = true;
- expect(component._convertValue(v({ sth: 'something' }))).toEqual(v({ sth: 'something' }));
+ const testConvertValue = (value, result) =>
+ expect(component._convertValue(v(value)).value).toBe(result);
+
+ it('should leave a string as it is', () => {
+ testConvertValue('something', 'something')
+ });
+
+ it('should leave an int as it is', () => {
+ testConvertValue(29, 29)
+ });
+
+ it('should convert arrays with any type to string', () => {
+ testConvertValue([1, 2, 3], '1, 2, 3')
+ testConvertValue([{ sth: 'something' }], '{"sth":"something"}')
+ testConvertValue([1, 'two', { 3: 'three' }], '1, two, {"3":"three"}')
+ });
+
+ it('should convert only allow objects if renderObjects is set to true', () => {
+ expect(component._convertValue(v({ sth: 'something' }))).toBe(undefined);
+ component.renderObjects = true;
+ expect(component._convertValue(v({ sth: 'something' }))).toEqual(v({ sth: 'something' }));
+ });
});
it('tests _insertFlattenObjects', () => {