"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const constants_js_1 = require("./constants.js");
(0, vitest_1.describe)('redis plugin de-serialize', () => {
    (0, vitest_1.test)('redis action config', () => {
        const noCommand = {
            connection: {
                url: {
                    urlString: 'this.is.test.url'
                }
            }
        };
        const protoNoCommand = constants_js_1.PLUGIN_ID_TO_PROTO_ACTION_CONFIGURATION_OBJECT_CALLABLE['redis'](noCommand);
        (0, vitest_1.expect)(protoNoCommand.commandType.case).toBeUndefined();
        const withCommand = {
            structured: {
                get: {
                    key: 'awef'
                }
            }
        };
        const protoWithCommand = constants_js_1.PLUGIN_ID_TO_PROTO_ACTION_CONFIGURATION_OBJECT_CALLABLE['redis'](withCommand);
        (0, vitest_1.expect)(protoWithCommand.commandType.case).toEqual('structured');
        const pluginStructured = protoWithCommand.commandType.value;
        (0, vitest_1.expect)(pluginStructured.action.case).toEqual('get');
    });
    (0, vitest_1.test)('redis datasource config', () => {
        const config = {
            connection: {
                url: {
                    urlString: 'this.is.test.url'
                }
            }
        };
        const proto = constants_js_1.PLUGIN_ID_TO_PROTO_DATASOURCE_CONFIGURATION_OBJECT_CALLABLE['redis'](config);
        const connectionProto = proto.connection;
        (0, vitest_1.expect)(connectionProto.connectionType.case).toEqual('url');
    });
});
(0, vitest_1.describe)('salesforce plugin de-serialize', () => {
    (0, vitest_1.test)('salesforce datasource config', () => {
        const config = {
            authTypeField: 'authTypeField',
            authConfig: {
                useFixedPasswordCreds: true,
                authToken: '{{oauth.token}}',
                authType: 'password'
            },
            connection: {
                auth: {
                    passwordGrantFlow: {
                        clientId: 'client id',
                        clientSecret: 'client secret',
                        tokenUrl: 'url',
                        password: 'password',
                        username: 'username'
                    }
                },
                instanceUrl: 'https://domain.sandbox.my.salesforce.com/'
            },
            name: 'test sfdc plugin'
        };
        const datasourceConfiguration = constants_js_1.PLUGIN_ID_TO_PROTO_DATASOURCE_CONFIGURATION_OBJECT_CALLABLE['salesforce'](config);
        const proto = datasourceConfiguration;
        (0, vitest_1.expect)(proto.connection?.auth).toBeDefined();
        (0, vitest_1.expect)(proto.connection?.instanceUrl).toEqual('https://domain.sandbox.my.salesforce.com/');
        (0, vitest_1.expect)(datasourceConfiguration.authTypeField).toEqual('authTypeField');
        (0, vitest_1.expect)(datasourceConfiguration.authConfig).toEqual({
            useFixedPasswordCreds: true,
            authToken: '{{oauth.token}}',
            authType: 'password'
        });
    });
    (0, vitest_1.test)('salesforce action config', () => {
        const config = {
            authConfig: {
                useFixedPasswordCreds: true,
                authToken: '{{oauth.token}}',
                authType: 'password'
            },
            soql: {
                sqlBody: 'select Id from Contact limit 200'
            }
        };
        const proto = constants_js_1.PLUGIN_ID_TO_PROTO_ACTION_CONFIGURATION_OBJECT_CALLABLE['salesforce'](config);
        (0, vitest_1.expect)(proto.salesforceAction.case).toEqual('soql');
    });
});
(0, vitest_1.describe)('cosmosdb plugin de-serialize', () => {
    (0, vitest_1.test)('cosmosdb action config', () => {
        const noCommand = {
            connection: {
                host: 'this.is.test.url',
                port: 443,
                databaseId: 'this.is.a.test.db',
                auth: {
                    key: {
                        masterKey: 'this.is.a.test.key'
                    }
                }
            }
        };
        const protoNoCommand = constants_js_1.PLUGIN_ID_TO_PROTO_ACTION_CONFIGURATION_OBJECT_CALLABLE['cosmosdb'](noCommand);
        (0, vitest_1.expect)(protoNoCommand.cosmosdbAction.case).toBeUndefined();
        const withCommand = {
            sql: {
                singleton: {
                    containerId: 'this.is.a.test.container',
                    query: 'this.is.a.test.query',
                    crossPartition: true,
                    partitionKey: 'this.is.a.test.partition.key'
                }
            }
        };
        const protoWithCommand = constants_js_1.PLUGIN_ID_TO_PROTO_ACTION_CONFIGURATION_OBJECT_CALLABLE['cosmosdb'](withCommand);
        (0, vitest_1.expect)(JSON.parse(JSON.stringify(protoWithCommand))).toEqual({
            cosmosdbAction: {
                case: 'sql',
                value: {
                    singleton: {
                        containerId: 'this.is.a.test.container',
                        query: 'this.is.a.test.query',
                        crossPartition: true,
                        partitionKey: 'this.is.a.test.partition.key'
                    }
                }
            }
        });
        (0, vitest_1.expect)(protoWithCommand.cosmosdbAction.case).toEqual('sql');
        const pluginStructured = protoWithCommand.cosmosdbAction.value;
        (0, vitest_1.expect)(pluginStructured.action.case).toEqual('singleton');
    });
    (0, vitest_1.test)('cosmosdb datasource config', () => {
        const config = {
            connection: {
                host: 'this.is.test.url',
                port: 443,
                databaseId: 'this.is.a.test.db',
                auth: {
                    key: {
                        masterKey: 'this.is.a.test.key'
                    }
                }
            }
        };
        const proto = constants_js_1.PLUGIN_ID_TO_PROTO_DATASOURCE_CONFIGURATION_OBJECT_CALLABLE['cosmosdb'](config);
        const connectionProto = proto.connection;
        (0, vitest_1.expect)(JSON.parse(JSON.stringify(connectionProto))).toEqual({
            host: 'this.is.test.url',
            port: 443,
            databaseId: 'this.is.a.test.db',
            auth: {
                key: {
                    masterKey: 'this.is.a.test.key'
                }
            }
        });
    });
});
//# sourceMappingURL=constants.test.js.map