"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const react_2 = require("@testing-library/react");
const react_router_dom_1 = require("react-router-dom");
const DatasetTools_1 = require("../DatasetTools");
require("@testing-library/jest-dom/extend-expect");
describe('DatasetTools component', () => {
    it('provides expected tools for a draft (admin)', () => {
        (0, react_2.render)(react_1.default.createElement(DatasetTools_1.DatasetTools, { hasEdit: true, isPublic: true, isAdmin: true, datasetId: 'test000001', hasSnapshot: true, isDatasetAdmin: true }), { wrapper: react_router_dom_1.MemoryRouter });
        expect(react_2.screen.queryByLabelText('Files')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Share')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Versioning')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Admin')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Download')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Metadata')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Delete')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('View Draft')).not.toBeInTheDocument();
    });
    it('provides expected tools for a snapshot (admin)', () => {
        (0, react_2.render)(react_1.default.createElement(DatasetTools_1.DatasetTools, { hasEdit: true, isPublic: true, isAdmin: true, snapshotId: '1.0.0', datasetId: 'test000001', hasSnapshot: true, isDatasetAdmin: true }), { wrapper: react_router_dom_1.MemoryRouter });
        expect(react_2.screen.queryByLabelText('Files')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('View Draft')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Download')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Metadata')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Deprecate Version')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Delete')).not.toBeInTheDocument();
    });
    it('provides expected tools for a draft (read only)', () => {
        (0, react_2.render)(react_1.default.createElement(DatasetTools_1.DatasetTools, { hasEdit: false, isPublic: true, isAdmin: false, datasetId: 'test000001', hasSnapshot: true, isDatasetAdmin: false }), { wrapper: react_router_dom_1.MemoryRouter });
        expect(react_2.screen.queryByLabelText('Files')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('View Draft')).not.toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Download')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Metadata')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Deprecate Version')).not.toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Delete')).not.toBeInTheDocument();
    });
    it('provides expected tools for a snapshot (read only)', () => {
        (0, react_2.render)(react_1.default.createElement(DatasetTools_1.DatasetTools, { hasEdit: false, isPublic: true, isAdmin: false, snapshotId: '1.0.0', datasetId: 'test000001', hasSnapshot: true, isDatasetAdmin: false }), { wrapper: react_router_dom_1.MemoryRouter });
        expect(react_2.screen.queryByLabelText('Files')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('View Draft')).not.toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Download')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Metadata')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Deprecate Version')).not.toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Delete')).not.toBeInTheDocument();
    });
    it('links to draft page when snapshotId is undefined', () => {
        (0, react_2.render)(react_1.default.createElement(DatasetTools_1.DatasetTools, { hasEdit: false, isPublic: true, isAdmin: false, datasetId: 'test000001', hasSnapshot: true, isDatasetAdmin: false }), { wrapper: react_router_dom_1.MemoryRouter });
        expect(react_2.screen.queryByLabelText('Download')).toBeInTheDocument();
        expect(react_2.screen.queryByRole('link', { name: 'Download' })).toHaveAttribute('href', '/datasets/test000001/download');
    });
    it('links to snapshot page when snapshotId is defined', () => {
        (0, react_2.render)(react_1.default.createElement(DatasetTools_1.DatasetTools, { hasEdit: false, isPublic: true, isAdmin: false, datasetId: 'test000001', snapshotId: '1.0.0', hasSnapshot: true, isDatasetAdmin: false }), { wrapper: react_router_dom_1.MemoryRouter });
        expect(react_2.screen.queryByLabelText('Download')).toBeInTheDocument();
        expect(react_2.screen.queryByRole('link', { name: 'Download' })).toHaveAttribute('href', '/datasets/test000001/versions/1.0.0/download');
    });
});
