"use strict";
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 react_2 = require("@testing-library/react");
var TargetBox_1 = require("./TargetBox");
var mockOnAppendFile = jest.fn();
var setUp = function () {
    return (0, react_2.render)(react_1.default.createElement(TargetBox_1.TargetBox, { onAppendFile: mockOnAppendFile }));
};
describe('TargetBox', function () {
    afterEach(function () {
        jest.clearAllMocks();
    });
    it('should renders well', function () {
        setUp();
        expect(react_2.screen.getByText('Drag an image here')).toBeInTheDocument();
    });
    it('should activates drag state on drag over with acceptable file type', function () {
        var container = setUp().container;
        var dropZone = container.firstChild;
        react_2.fireEvent.dragOver(dropZone, {
            dataTransfer: { types: ['Files'], dropEffect: 'copy' }
        });
        expect(dropZone).toHaveClass('isActive');
    });
    it('should does not activate drag state with unacceptable file type', function () {
        var container = setUp().container;
        var dropZone = container.firstChild;
        react_2.fireEvent.dragOver(dropZone, {
            dataTransfer: { types: ['Text'], dropEffect: 'none' }
        });
        expect(dropZone).not.toHaveClass('isActive');
    });
    it('should deactivates drag state on drag leave', function () {
        var container = setUp().container;
        var dropZone = container.firstChild;
        react_2.fireEvent.dragOver(dropZone, { dataTransfer: { types: ['Files'] } });
        expect(dropZone).toHaveClass('isActive');
        react_2.fireEvent.dragLeave(dropZone);
        expect(dropZone).not.toHaveClass('isActive');
    });
    it('should calls onAppendFile with the dropped file', function () {
        var file = new File(['test content'], 'test.png', { type: 'image/png' });
        var container = setUp().container;
        var dropZone = container.firstChild;
        react_2.fireEvent.drop(dropZone, {
            dataTransfer: {
                files: [file],
                types: ['Files']
            }
        });
        expect(mockOnAppendFile).toHaveBeenCalledWith(file);
    });
    it('should does not call onAppendFile if dropped item is not of file type', function () {
        var container = setUp().container;
        var dropZone = container.firstChild;
        react_2.fireEvent.drop(dropZone, {
            dataTransfer: {
                types: ['Text']
            }
        });
        expect(mockOnAppendFile).not.toHaveBeenCalled();
    });
});
