"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var CrosswalksDisplay = __importStar(require("../../../contexts/CrosswalksDisplayContext"));
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
var CrosswalkDragPreview_1 = require("./CrosswalkDragPreview");
var react_2 = require("@testing-library/react");
var core_1 = require("@dnd-kit/core");
jest.mock('@dnd-kit/core', function () { return (__assign(__assign({}, jest.requireActual('@dnd-kit/core')), { useDndMonitor: jest.fn() })); });
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { canAddCrosswalk: jest.fn().mockReturnValue(true) })); });
var defaultProps = {
    crosswalk: { uri: 'entities/1/crosswalks/1', type: 'configuration/sources/FB', value: '123' }
};
var setUp = function (props) {
    if (props === void 0) { props = defaultProps; }
    var metadata = {
        sources: [
            {
                uri: 'configuration/sources/FB',
                label: 'Facebook'
            }
        ]
    };
    var Providers = function (_a) {
        var children = _a.children;
        return (react_1.default.createElement(core_1.DndContext, null,
            react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: { metadata: metadata } }, children)));
    };
    return (0, react_2.render)(react_1.default.createElement(CrosswalkDragPreview_1.CrosswalkDragPreview, __assign({}, props)), { wrapper: Providers });
};
describe('CrosswalkDragPreview tests', function () {
    beforeAll(function () {
        jest.spyOn(CrosswalksDisplay, 'useCrosswalkColor').mockImplementation(function (crosswalks) { return crosswalks === null || crosswalks === void 0 ? void 0 : crosswalks.value; });
    });
    it('should render correctly', function () {
        setUp();
        expect(react_2.screen.getByText('Facebook')).toBeInTheDocument();
        expect(react_2.screen.getByText('F')).toBeInTheDocument();
        expect(react_2.screen.getByTestId('cw-colored-block')).toHaveClass('noDrop');
    });
    it('should able for drop', function () {
        var onDragOver;
        core_1.useDndMonitor.mockImplementation(function (listeners) {
            onDragOver = listeners.onDragOver;
        });
        setUp();
        (0, react_2.act)(function () {
            onDragOver({
                over: {
                    data: {
                        current: {
                            attributeType: 'testAttrTypeUri'
                        }
                    }
                }
            });
        });
        expect(react_2.screen.getByTestId('cw-colored-block')).not.toHaveClass('noDrop');
    });
});
