Skip to content

Commit

Permalink
Merge 63de4da into 13b02bc
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeman committed Feb 14, 2019
2 parents 13b02bc + 63de4da commit 9d89be1
Show file tree
Hide file tree
Showing 10 changed files with 378 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"react-dom": "^16.7.0",
"react-redux": "^6.0.0",
"react-router-dom": "^4.3.1",
"react-tinymce": "^0.7.0",
"react-toastify": "^4.5.2",
"redux": "^4.0.1",
"redux-mock-store": "^1.5.3",
Expand Down
4 changes: 4 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>LearnGround</title>
</head>

<body>
<!--Import jQuery before materialize.js -->
<script
Expand All @@ -46,6 +47,9 @@
const instances = M.Modal.init(elems);
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.5.6/tinymce.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.5.6/jquery.tinymce.min.js"></script>
<div id="app"></div>
</body>
</html>
3 changes: 2 additions & 1 deletion src/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { Home } from './home';
import { Signup } from './signup';
import { Login } from './login';
import Article from './article';
import { Article, CreateArticle } from './article';
import Footer from './footer';
import Navbar from './navBar/NavbarComponent';
import { Subject } from './subject';
Expand All @@ -20,6 +20,7 @@ const App = () => (
<Route path="/login" component={Login} exact />
<Route path="/subject" component={Subject} exact />
<Route path="/articles" component={Article} exact />
<Route path="/create-article" component={CreateArticle} exact />
</Switch>
<Footer />
</Fragment>
Expand Down
49 changes: 49 additions & 0 deletions src/app/article/CreateArticleComponent.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import Editor from './EditorComponent';
import './create-article.scss';

const CreateArticleComponent = () => {
return (
<div className="create-wrapper">
<div className="create-container">
<div className="content-container">
<div className="create-author-details">
<div className="author-photo" />
<div className="create-author-name">
<div className="create-auth-name">Tom Henkins</div>
</div>
</div>
<div className="create-form">
<form className="article-form">
<input type="text" placeholder="Title" />
<select
name="category"
defaultValue=""
className="browser-default"
required
>
<option value="" disabled>
Select Category
</option>
<option value="mathematics">Mathematics</option>
<option value="arts">Arts</option>
<option value="science">Science</option>
<option value="engineering">Engineering</option>
<option value="technology">Technology</option>
</select>
<input type="text" placeholder="Description" />
<div className="create-article-text">
<Editor />
</div>
<div className="create-article-button">
<button type="submit">POST</button>
</div>
</form>
</div>
</div>
</div>
</div>
);
};

export default CreateArticleComponent;
8 changes: 8 additions & 0 deletions src/app/article/CreateArticleContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import CreateArticleComponent from './CreateArticleComponent';

const CreateArticleContainer = () => {
return <CreateArticleComponent />;
};

export default CreateArticleContainer;
18 changes: 18 additions & 0 deletions src/app/article/EditorComponent.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import TinyMCE from 'react-tinymce';

const Editor = () => {
return (
<TinyMCE
placeholder="<p>This is the initial content of the editor</p>"
config={{
plugins: 'autolink link image lists print preview',
toolbar: 'undo redo | bold italic | alignleft aligncenter alignright',
width: '100%',
height: '30%',
}}
/>
);
};

export default Editor;
116 changes: 116 additions & 0 deletions src/app/article/__snapshots__/article.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,119 @@ exports[`Article Container should render the Article Page 1`] = `
</ArticleComponent>
</ArticleContainer>
`;

exports[`CreateArticle should render the CreateArticleComponent 1`] = `
<div
className="create-wrapper"
>
<div
className="create-container"
>
<div
className="content-container"
>
<div
className="create-author-details"
>
<div
className="author-photo"
/>
<div
className="create-author-name"
>
<div
className="create-auth-name"
>
Tom Henkins
</div>
</div>
</div>
<div
className="create-form"
>
<form
className="article-form"
>
<input
placeholder="Title"
type="text"
/>
<select
className="browser-default"
defaultValue=""
name="category"
required={true}
>
<option
disabled={true}
value=""
>
Select Category
</option>
<option
value="mathematics"
>
Mathematics
</option>
<option
value="arts"
>
Arts
</option>
<option
value="science"
>
Science
</option>
<option
value="engineering"
>
Engineering
</option>
<option
value="technology"
>
Technology
</option>
</select>
<input
placeholder="Description"
type="text"
/>
<div
className="create-article-text"
>
<Editor />
</div>
<div
className="create-article-button"
>
<button
type="submit"
>
POST
</button>
</div>
</form>
</div>
</div>
</div>
</div>
`;

exports[`CreateArticle should render the CreateArticleContainer 1`] = `<CreateArticleComponent />`;

exports[`CreateArticle should render the EditorComponent 1`] = `
<TinyMCE
config={
Object {
"height": "30%",
"plugins": "autolink link image lists print preview",
"toolbar": "undo redo | bold italic | alignleft aligncenter alignright",
"width": "100%",
}
}
content=""
placeholder="<p>This is the initial content of the editor</p>"
/>
`;
25 changes: 24 additions & 1 deletion src/app/article/article.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React from 'react';
import { mount } from 'enzyme';
import { mount, shallow } from 'enzyme';
import ArticleContainer from './ArticleContainer';
import CreateArticleContainer from './CreateArticleContainer';
import CreateArticleComponent from './CreateArticleComponent';
import EditorComponent from './EditorComponent';

describe('Article Container', () => {
it('should render the Article Page', () => {
Expand All @@ -9,3 +12,23 @@ describe('Article Container', () => {
expect(component).toMatchSnapshot();
});
});

describe('CreateArticle', () => {
it('should render the CreateArticleContainer', () => {
const component = shallow(<CreateArticleContainer />);
expect(component.exists()).toBe(true);
expect(component).toMatchSnapshot();
});

it('should render the CreateArticleComponent', () => {
const component = shallow(<CreateArticleComponent />);
expect(component.exists()).toBe(true);
expect(component).toMatchSnapshot();
});

it('should render the EditorComponent', () => {
const component = shallow(<EditorComponent />);
expect(component.exists()).toBe(true);
expect(component).toMatchSnapshot();
});
});
Loading

0 comments on commit 9d89be1

Please sign in to comment.