mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-25 03:41:19 +00:00
* minro code edits * Added support for acknowledging code of conduct - Added CodeOfConduct component that shows links and a checkbox that must be acknwledged before seeing the public galley - Added verbose message for notebook publish error (when another notebook with the same name exists in the gallery) - Added a feature flag for enabling code of conduct acknowledgement * Added Info Component * minor edit * fixed failign tests * publish tab displayed only when code of conduct accepted * added code of conduct fetch during publish * fixed bug * added test and addressed PR comments * changed line endings * added comment * addressed PR comments
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { shallow } from "enzyme";
|
|
import * as sinon from "sinon";
|
|
import React from "react";
|
|
import { CodeOfConductComponent, CodeOfConductComponentProps } from "./CodeOfConductComponent";
|
|
import { IJunoResponse, JunoClient } from "../../../Juno/JunoClient";
|
|
import { HttpStatusCodes } from "../../../Common/Constants";
|
|
|
|
describe("CodeOfConductComponent", () => {
|
|
let sandbox: sinon.SinonSandbox;
|
|
let codeOfConductProps: CodeOfConductComponentProps;
|
|
|
|
beforeEach(() => {
|
|
sandbox = sinon.sandbox.create();
|
|
sandbox.stub(JunoClient.prototype, "acceptCodeOfConduct").returns({
|
|
status: HttpStatusCodes.OK,
|
|
data: true
|
|
} as IJunoResponse<boolean>);
|
|
const junoClient = new JunoClient(undefined);
|
|
codeOfConductProps = {
|
|
junoClient: junoClient,
|
|
onAcceptCodeOfConduct: jest.fn()
|
|
};
|
|
});
|
|
|
|
afterEach(() => {
|
|
sandbox.restore();
|
|
});
|
|
|
|
it("renders", () => {
|
|
const wrapper = shallow(<CodeOfConductComponent {...codeOfConductProps} />);
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it("onAcceptedCodeOfConductCalled", async () => {
|
|
const wrapper = shallow(<CodeOfConductComponent {...codeOfConductProps} />);
|
|
wrapper
|
|
.find(".genericPaneSubmitBtn")
|
|
.first()
|
|
.simulate("click");
|
|
await Promise.resolve();
|
|
expect(codeOfConductProps.onAcceptCodeOfConduct).toBeCalled();
|
|
});
|
|
});
|