import * as React from "react";
import {mount} from "enzyme";
import {ViewSwitcherToggle} from "./ViewSwitcherToggle";
import {ViewSwitcherHits} from "./ViewSwitcherHits";
import {Select} from "../../ui";
import {SearchkitManager} from "../../../core";
import {
fastClick, hasClass, jsxToHTML, printPrettyHtml
} from "../../__test__/TestHelpers"
const map = require("lodash/map")
describe("View Switcher Hits component", () => {
describe('renders correctly', () => {
beforeEach(() => {
this.searchkit = SearchkitManager.mock()
const MovieHitsGridItem = (props) => {
return (
{props.result.title}
)
}
const MovieHitsListItem = (props) => {
return (
{props.result.title}
)
}
const MovieList = (props)=> {
return (
{map(props.hits, "_id").join(",")}
)
}
this.searchkit.setResults({
hits:{
hits:[{_id:1, title:1},{_id:2,title:2}],
total:2
}
})
this.setWrapper = (props={})=> {
this.wrapper = mount(
)
}
this.ViewOptionsAccessor = this.searchkit.accessors.accessors[0]
});
it("View Switcher Hits", ()=> {
this.setWrapper()
expect(this.wrapper.html()).toEqual(jsxToHTML(
))
fastClick(this.wrapper.find(".sk-toggle-option").at(1))
this.wrapper.update()
expect(this.wrapper.html()).toEqual(jsxToHTML(
))
fastClick(this.wrapper.find(".sk-toggle-option").at(2))
expect(this.wrapper.html()).toEqual(jsxToHTML(
))
})
it("custom mod, className, listComponent", ()=> {
this.setWrapper({
mod:"my-view-switcher", className:"customClass",
listComponent:Select
})
expect(this.wrapper.html()).toEqual(jsxToHTML(
))
})
})
})