mirror of
https://github.com/fleetdm/fleet
synced 2026-05-20 15:38:39 +00:00
* Style all settings side panels * Add builtin label icons * Update tests aligning jest userStub and adminUserStub * Update tests adding cypress checks for user teams/roles
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
import React from "react";
|
|
import { mount } from "enzyme";
|
|
import { noop } from "lodash";
|
|
|
|
import QueryDetailsSidePanel from "components/side_panels/QueryDetailsSidePanel";
|
|
import { queryStub, adminUserStub } from "test/stubs";
|
|
|
|
describe("QueryDetailsSidePanel - component", () => {
|
|
it("renders", () => {
|
|
const component = mount(
|
|
<QueryDetailsSidePanel
|
|
onEditQuery={noop}
|
|
query={queryStub}
|
|
currentUser={adminUserStub}
|
|
/>
|
|
);
|
|
|
|
expect(component.length).toEqual(1);
|
|
});
|
|
|
|
it("renders a read-only Kolide Ace component with the query text", () => {
|
|
const component = mount(
|
|
<QueryDetailsSidePanel
|
|
onEditQuery={noop}
|
|
query={queryStub}
|
|
currentUser={adminUserStub}
|
|
/>
|
|
);
|
|
const aceEditor = component.find("FleetAce");
|
|
|
|
expect(aceEditor.length).toEqual(1);
|
|
expect(aceEditor.prop("value")).toEqual(queryStub.query);
|
|
expect(aceEditor.prop("readOnly")).toEqual(true);
|
|
});
|
|
|
|
it("calls the onEditQuery prop when Edit/Run Query is clicked", () => {
|
|
const spy = jest.fn();
|
|
const component = mount(
|
|
<QueryDetailsSidePanel
|
|
onEditQuery={spy}
|
|
query={queryStub}
|
|
currentUser={adminUserStub}
|
|
/>
|
|
);
|
|
const button = component.find("Button");
|
|
|
|
button.simulate("click");
|
|
|
|
expect(spy).toHaveBeenCalledWith(queryStub);
|
|
});
|
|
});
|