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);
};
import React from 'react';
import * as CrosswalksDisplay from '../../../contexts/CrosswalksDisplayContext';
import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
import { CrosswalkDragPreview } from './CrosswalkDragPreview';
import { act, render, screen } from '@testing-library/react';
import { DndContext, useDndMonitor } from '@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.createElement(DndContext, null,
            React.createElement(MdmModuleProvider, { values: { metadata: metadata } }, children)));
    };
    return render(React.createElement(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(screen.getByText('Facebook')).toBeInTheDocument();
        expect(screen.getByText('F')).toBeInTheDocument();
        expect(screen.getByTestId('cw-colored-block')).toHaveClass('noDrop');
    });
    it('should able for drop', function () {
        var onDragOver;
        useDndMonitor.mockImplementation(function (listeners) {
            onDragOver = listeners.onDragOver;
        });
        setUp();
        act(function () {
            onDragOver({
                over: {
                    data: {
                        current: {
                            attributeType: 'testAttrTypeUri'
                        }
                    }
                }
            });
        });
        expect(screen.getByTestId('cw-colored-block')).not.toHaveClass('noDrop');
    });
});
