mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 01:11:25 +00:00
* Adding computed properties to Settings tab for containers * Fixing files for prettier and a test snapshot
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
import * as DataModels from "Contracts/DataModels";
|
|
import { shallow } from "enzyme";
|
|
import React from "react";
|
|
import { ComputedPropertiesComponent, ComputedPropertiesComponentProps } from "./ComputedPropertiesComponent";
|
|
|
|
describe("ComputedPropertiesComponent", () => {
|
|
const initialComputedPropertiesContent: DataModels.ComputedProperties = [
|
|
{
|
|
name: "prop1",
|
|
query: "query1",
|
|
},
|
|
];
|
|
const baseProps: ComputedPropertiesComponentProps = {
|
|
computedPropertiesContent: initialComputedPropertiesContent,
|
|
computedPropertiesContentBaseline: initialComputedPropertiesContent,
|
|
logComputedPropertiesSuccessMessage: () => {
|
|
return;
|
|
},
|
|
onComputedPropertiesContentChange: () => {
|
|
return;
|
|
},
|
|
onComputedPropertiesDirtyChange: () => {
|
|
return;
|
|
},
|
|
resetShouldDiscardComputedProperties: () => {
|
|
return;
|
|
},
|
|
shouldDiscardComputedProperties: false,
|
|
};
|
|
|
|
it("renders", () => {
|
|
const wrapper = shallow(<ComputedPropertiesComponent {...baseProps} />);
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it("computed properties are reset", () => {
|
|
const wrapper = shallow(<ComputedPropertiesComponent {...baseProps} />);
|
|
|
|
const computedPropertiesComponentInstance = wrapper.instance() as ComputedPropertiesComponent;
|
|
const resetComputedPropertiesEditorMockFn = jest.fn();
|
|
computedPropertiesComponentInstance.resetComputedPropertiesEditor = resetComputedPropertiesEditorMockFn;
|
|
|
|
wrapper.setProps({ shouldDiscardComputedProperties: true });
|
|
wrapper.update();
|
|
expect(resetComputedPropertiesEditorMockFn.mock.calls.length).toEqual(1);
|
|
});
|
|
|
|
it("dirty is set", () => {
|
|
let computedPropertiesComponent = new ComputedPropertiesComponent(baseProps);
|
|
expect(computedPropertiesComponent.IsComponentDirty()).toEqual(false);
|
|
|
|
const newProps = { ...baseProps, computedPropertiesContent: undefined as DataModels.ComputedProperties };
|
|
computedPropertiesComponent = new ComputedPropertiesComponent(newProps);
|
|
expect(computedPropertiesComponent.IsComponentDirty()).toEqual(true);
|
|
});
|
|
});
|