"use strict";
/*
 *  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *  SPDX-License-Identifier: Apache-2.0
 */
Object.defineProperty(exports, "__esModule", { value: true });
const swb_app_1 = require("@aws/swb-app");
const envTypeConfigService_1 = require("./envTypeConfigService");
describe('envTypeConfigService', () => {
    let mockEnvironmentTypeConfigService;
    let mockMetadataService;
    let envTypeConfigPlugin;
    beforeEach(() => {
        jest.clearAllMocks();
        mockEnvironmentTypeConfigService = {};
        mockMetadataService = {};
        envTypeConfigPlugin = new envTypeConfigService_1.EnvTypeConfigService(mockEnvironmentTypeConfigService, mockMetadataService);
    });
    describe('delete', () => {
        const deleteRequest = { envTypeId: 'envTypeId', envTypeConfigId: 'envTypeConfigId' };
        test('throws Conflict Error when associations exist', async () => {
            mockMetadataService.listDependentMetadata = jest.fn().mockReturnValueOnce({
                data: [{ pk: 'mockResult', sk: 'mockResult', id: 'mockResult' }],
                paginationToken: undefined
            });
            // OPERATE n CHECK
            await expect(() => envTypeConfigPlugin.deleteEnvTypeConfig(deleteRequest)).rejects.toThrow(swb_app_1.ConflictError);
        });
        test('deletes when no associations exist', async () => {
            mockMetadataService.listDependentMetadata = jest.fn().mockReturnValueOnce({ data: [] });
            mockEnvironmentTypeConfigService.softDeleteEnvironmentTypeConfig = jest.fn().mockReturnValueOnce({});
            // OPERATE n CHECK
            await expect(() => envTypeConfigPlugin.deleteEnvTypeConfig(deleteRequest)).resolves;
        });
    });
});
//# sourceMappingURL=envTypeConfigService.test.js.map