// Copyright (C) The Arvados Authors. All rights reserved.
//
// SPDX-License-Identifier: AGPL-3.0
import * as React from "react";
import { mount, configure } from "enzyme";
// import { SearchBarView, DEFAULT_SEARCH_DEBOUNCE } from "./search-bar-view";
import * as Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
describe("", () => {
jest.useFakeTimers();
let onSearch: () => void;
beforeEach(() => {
onSearch = jest.fn();
});
describe("on input value change", () => {
// TODO fix tests and delete beneath one
it("fix tests", () => {
const test = 1;
expect(test).toBe(1);
});
// it("calls onSearch after default timeout", () => {
// const searchBar = mount();
// searchBar.find("input").simulate("change", { target: { value: "current value" } });
// expect(onSearch).not.toBeCalled();
// jest.runTimersToTime(DEFAULT_SEARCH_DEBOUNCE);
// expect(onSearch).toBeCalledWith("current value");
// });
// it("calls onSearch after the time specified in props has passed", () => {
// const searchBar = mount();
// searchBar.find("input").simulate("change", { target: { value: "current value" } });
// jest.runTimersToTime(1000);
// expect(onSearch).not.toBeCalled();
// jest.runTimersToTime(1000);
// expect(onSearch).toBeCalledWith("current value");
// });
// it("calls onSearch only once after no change happened during the specified time", () => {
// const searchBar = mount();
// searchBar.find("input").simulate("change", { target: { value: "current value" } });
// jest.runTimersToTime(500);
// searchBar.find("input").simulate("change", { target: { value: "changed value" } });
// jest.runTimersToTime(1000);
// expect(onSearch).toHaveBeenCalledTimes(1);
// });
// it("calls onSearch again after the specified time has passed since previous call", () => {
// const searchBar = mount();
// searchBar.find("input").simulate("change", { target: { value: "current value" } });
// jest.runTimersToTime(500);
// searchBar.find("input").simulate("change", { target: { value: "intermediate value" } });
// jest.runTimersToTime(1000);
// expect(onSearch).toBeCalledWith("intermediate value");
// searchBar.find("input").simulate("change", { target: { value: "latest value" } });
// jest.runTimersToTime(1000);
// expect(onSearch).toBeCalledWith("latest value");
// expect(onSearch).toHaveBeenCalledTimes(2);
// });
});
});
const mockSearchProps = () => ({
currentView: '',
open: true,
onSetView: jest.fn(),
openView: jest.fn(),
loseView: jest.fn(),
closeView: jest.fn(),
saveRecentQuery: jest.fn(),
loadRecentQueries: () => ['test'],
saveQuery: jest.fn(),
deleteSavedQuery: jest.fn(),
openSearchView: jest.fn(),
editSavedQuery: jest.fn(),
navigateTo: jest.fn(),
searchDataOnEnter: jest.fn()
});