"use strict";
var __webpack_exports__ = {};
const transformVariableValue_js_namespaceObject = require("../../utils/transformVariableValue.js");
describe('transformVariableValue', ()=>{
    test('should return value as it is when targetCollectionFiled.type is "belongsTo" and value is not an array', ()=>{
        const value = {
            name: 'test'
        };
        const deps = {
            targetCollectionField: {
                type: 'belongsTo',
                uiSchema: {
                    'x-component': 'Text'
                }
            }
        };
        const result = (0, transformVariableValue_js_namespaceObject.transformVariableValue)(value, deps);
        expect(result).toBe(value);
    });
    test('should return value as it is when targetCollectionFiled.type is "hasOne" and value is not an array', ()=>{
        const value = {
            name: 'test'
        };
        const deps = {
            targetCollectionField: {
                type: 'hasOne',
                uiSchema: {
                    'x-component': 'Text'
                }
            }
        };
        const result = (0, transformVariableValue_js_namespaceObject.transformVariableValue)(value, deps);
        expect(result).toBe(value);
    });
    test('should return an array containing the value when targetCollectionFiled.type is "hasMany" and value is not an array', ()=>{
        const value = {
            name: 'test'
        };
        const deps = {
            targetCollectionField: {
                type: 'hasMany',
                uiSchema: {
                    'x-component': 'Text'
                }
            }
        };
        const result = (0, transformVariableValue_js_namespaceObject.transformVariableValue)(value, deps);
        expect(result).toEqual([
            value
        ]);
    });
    test('should return value as it is when targetCollectionFiled.type is "hasMany" and value is an array', ()=>{
        const value = [
            {
                name: 'test1'
            },
            {
                name: 'test2'
            }
        ];
        const deps = {
            targetCollectionField: {
                type: 'hasMany',
                uiSchema: {
                    'x-component': 'Text'
                }
            }
        };
        const result = (0, transformVariableValue_js_namespaceObject.transformVariableValue)(value, deps);
        expect(result).toBe(value);
    });
    test('should return value as it is when targetCollectionFiled.type is "belongsToMany" and value is not an array', ()=>{
        const value = {
            name: 'test'
        };
        const deps = {
            targetCollectionField: {
                type: 'belongsToMany',
                uiSchema: {
                    'x-component': 'Text'
                }
            }
        };
        const result = (0, transformVariableValue_js_namespaceObject.transformVariableValue)(value, deps);
        expect(result).toEqual([
            value
        ]);
    });
    test('should return an array containing the value when targetCollectionFiled.type is "belongsToMany" and value is an array', ()=>{
        const value = [
            {
                name: 'test1'
            },
            {
                name: 'test2'
            }
        ];
        const deps = {
            targetCollectionField: {
                type: 'belongsToMany',
                uiSchema: {
                    'x-component': 'Text'
                }
            }
        };
        const result = (0, transformVariableValue_js_namespaceObject.transformVariableValue)(value, deps);
        expect(result).toEqual(value);
    });
    test('json', ()=>{
        const value = {
            a: 1
        };
        const deps = {
            targetCollectionField: {
                type: 'string',
                interface: 'json',
                uiSchema: {
                    'x-component': 'Text'
                }
            }
        };
        const result = (0, transformVariableValue_js_namespaceObject.transformVariableValue)(value, deps);
        expect(result).toMatchInlineSnapshot('\n      {\n        "a": 1,\n      }\n    ');
    });
    test('value is undefined', ()=>{
        const value = void 0;
        const deps = {
            targetCollectionField: {
                type: 'belongsToMany',
                uiSchema: {
                    'x-component': 'AssociationField'
                }
            }
        };
        const result = (0, transformVariableValue_js_namespaceObject.transformVariableValue)(value, deps);
        expect(result).toMatchInlineSnapshot("undefined");
    });
});
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
