CEC-4100: Added push config changes to vin (#338)
This commit is contained in:
committed by
GitHub
parent
8e71cf6c8c
commit
bf0fb5363b
@@ -0,0 +1,9 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`General Confirmation Modal Should render 1`] = `
|
||||
<div
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div />
|
||||
</div>
|
||||
`;
|
||||
37
src/components/GeneralConfirmation/index.jsx
Normal file
37
src/components/GeneralConfirmation/index.jsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import {Dialog, DialogTitle, DialogContentText, Button, DialogActions, DialogContent} from '@material-ui/core';
|
||||
|
||||
const GeneralConfirmation = (props) => {
|
||||
return (
|
||||
<div>
|
||||
<Dialog open={props.open}
|
||||
onClose={props.close}>
|
||||
<DialogTitle id="alert-dialog-title">
|
||||
{props.title}
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText id="alert-dialog-description">
|
||||
{"Are you sure you want to : " + props.message}
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={props.close}>Cancel</Button>
|
||||
<Button variant="contained" color="secondary" onClick={() => { props.close(); props.actionFunction()}} autoFocus>
|
||||
Go
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
GeneralConfirmation.propTypes={
|
||||
open: PropTypes.bool.isRequired, // Boolean that determines if the modal should be open
|
||||
close: PropTypes.func.isRequired, // Function that sets the open state to false i.e. () => setOpen(false)
|
||||
message: PropTypes.any.isRequired, // What the user will see if being confirmed for the function to run
|
||||
actionFunction: PropTypes.func.isRequired, // Function that runs when user clicks Go
|
||||
title: PropTypes.any.isRequired, // The title of the modal that is opened
|
||||
}
|
||||
|
||||
export default GeneralConfirmation;
|
||||
20
src/components/GeneralConfirmation/index.test.jsx
Normal file
20
src/components/GeneralConfirmation/index.test.jsx
Normal file
@@ -0,0 +1,20 @@
|
||||
jest.mock("../Contexts/UserContext");
|
||||
|
||||
import React from "react";
|
||||
import { render, cleanup } from "@testing-library/react";
|
||||
import GeneralConfirmation from "./index";
|
||||
import addSnapshotSerializer from "../../utils/snapshot";
|
||||
|
||||
describe("General Confirmation Modal", () => {
|
||||
beforeAll(() => {
|
||||
addSnapshotSerializer(expect);
|
||||
});
|
||||
|
||||
it("Should render", () => {
|
||||
const { container } = render(
|
||||
<GeneralConfirmation open={true} close={()=>{}} message="Test Message" title="hello" actionFunction={()=>{}}/>
|
||||
);
|
||||
expect(container).toMatchSnapshot();
|
||||
cleanup();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user