Skip to content

Commit

Permalink
Finished UI testing. 100% JSX converage
Browse files Browse the repository at this point in the history
  • Loading branch information
yTakkar committed Jun 10, 2018
1 parent 922b83b commit 80d22c3
Show file tree
Hide file tree
Showing 145 changed files with 6,068 additions and 356 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Here's a video which will take you on a tour of this project!!
- [x] Some serious code refactoring
- [x] Crush some bugs
- [x] Don't need jQuery
- [ ] UI testing
- [x] UI testing
- [ ] Express routes testing
- [ ] Like comments
- [ ] Upgrade to React v16.3.0
Expand Down
17 changes: 4 additions & 13 deletions db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 09, 2018 at 07:00 PM
-- Generation Time: Jun 10, 2018 at 02:16 PM
-- Server version: 10.1.19-MariaDB
-- PHP Version: 5.6.28

Expand Down Expand Up @@ -496,7 +496,6 @@ INSERT INTO `notifications` (`notify_id`, `notify_by`, `notify_to`, `post_id`, `
(628, 28, 7, 0, 12, 'change_admin', 0, '1527942673969', 'unread'),
(629, 24, 16, 0, 0, 'follow', 0, '1528272513475', 'unread'),
(630, 24, 10, 0, 0, 'new_con', 0, '1528274472284', 'unread'),
(631, 24, 16, 90, 0, 'tag', 0, '1528387362128', 'unread'),
(632, 28, 24, 0, 0, 'follow', 0, '1528534489731', 'read');

-- --------------------------------------------------------
Expand Down Expand Up @@ -549,8 +548,7 @@ INSERT INTO `posts` (`post_id`, `user`, `description`, `imgSrc`, `filter`, `loca
(69, 24, 'That''s a #nice place to #travel', 'instagram_1518854775824.jpg', 'filter-normal', '', 'user', 0, '1518854775824'),
(71, 24, '#travel', 'instagram_1518857912246.jpg', 'filter-normal', '', 'group', 11, '1518857912246'),
(88, 24, 'Hello @ghalib @takkar #checkout', 'instagram_1518945386167.jpg', 'filter-normal', '', 'user', 0, '1518945386167'),
(89, 24, 'he @nobita, @doraemon #checkout, #dd #fgf', 'instagram_1518972814710.jpg', 'filter-ashby', 'A-301, 90 Feet Road, Dharavi, Mumbai, Maharashtra 400017, India', 'user', 0, '1518972814710'),
(90, 24, '', 'instagram_1528387359904.jpg', 'filter-normal', '', 'user', 0, '1528387359905');
(89, 24, 'he @nobita, @doraemon #checkout, #dd #fgf', 'instagram_1518972814710.jpg', 'filter-ashby', 'A-301, 90 Feet Road, Dharavi, Mumbai, Maharashtra 400017, India', 'user', 0, '1518972814710');

-- --------------------------------------------------------

Expand All @@ -564,13 +562,6 @@ CREATE TABLE `post_tags` (
`user` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `post_tags`
--

INSERT INTO `post_tags` (`post_tag_id`, `post_id`, `user`) VALUES
(1, 90, 16);

-- --------------------------------------------------------

--
Expand Down Expand Up @@ -1112,7 +1103,7 @@ ALTER TABLE `comments`
-- AUTO_INCREMENT for table `conversations`
--
ALTER TABLE `conversations`
MODIFY `con_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=41;
MODIFY `con_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=40;
--
-- AUTO_INCREMENT for table `favourites`
--
Expand Down Expand Up @@ -1187,7 +1178,7 @@ ALTER TABLE `tags`
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=50;
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
2 changes: 1 addition & 1 deletion dist/js/bundle.js

Large diffs are not rendered by default.

Binary file removed dist/posts/instagram_1528387359904.jpg
Binary file not shown.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ module.exports = {
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
snapshotSerializers: ['enzyme-to-json/serializer']
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"css-loader": "^0.28.11",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.4",
"eslint": "^4.13.0",
"eslint-plugin-react": "^7.5.1",
"handy-client-env": "^1.0.16",
Expand Down
17 changes: 9 additions & 8 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ import NotiSpeak from './others/noti-speak'
import SideBar from './others/sidebar/sidebar'
import AppRoutes from './App-routes'

@connect(store => (
{
unreadNotifications: store.Notification.unreadNotifications,
unreadMessages: store.Message.unreadMessages
}
))

export default class App extends Component {
class App extends Component {

componentDidMount = () => {
let { dispatch } = this.props
Expand All @@ -47,3 +40,11 @@ export default class App extends Component {
)
}
}

const mapStateToProps = store => ({
unreadNotifications: store.Notification.unreadNotifications,
unreadMessages: store.Message.unreadMessages
})

export default connect(mapStateToProps)(App)
export { App as PureApp }
21 changes: 21 additions & 0 deletions src/components/__test__/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import MockDataElement from '../../utils/__test__/mock-dataElement'
import { PureApp } from '../App'
import { shallow } from 'enzyme'

describe('App Component', () => {
MockDataElement()

// shallow snapshot
it('should match snapshot', () => {
const tree = shallow(
<PureApp
unreadNotifications={1}
unreadMessages={0}
dispatch={jest.fn()}
/>
)
expect(tree).toMatchSnapshot()
})

})
19 changes: 19 additions & 0 deletions src/components/__test__/__snapshots__/App.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`App Component should match snapshot 1`] = `
<BrowserRouter>
<div
className="app"
>
<Header />
<Connect(NotiSpeak)
un={1}
/>
<SideBar
uc={0}
un={1}
/>
<AppRoutes />
</div>
</BrowserRouter>
`;
8 changes: 4 additions & 4 deletions src/components/explore/photos/__test__/explore-photos.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react'
import { PureExpPhotos } from '../explore-photos'
import { shallow } from 'enzyme'
import ShallowRenderer from 'react-test-renderer/shallow'

describe('ExpPhotos Component', () => {

// shallow snapshot testing
it('should match snapshot', () => {
const renderer = new ShallowRenderer()
const result = renderer.render(
<PureExpPhotos/>
const result = shallow(
<PureExpPhotos
dispatch={jest.fn()}
/>
)
expect(result).toMatchSnapshot()
})
Expand Down
4 changes: 1 addition & 3 deletions src/components/explore/photos/__test__/photo-gallery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { PureExplorePhotoGallery } from '../photo-gallery'
import { shallow, mount } from 'enzyme'
import Explore from '../../../../store/mockStore/mock-reducers/Explore'
import { BrowserRouter as Router } from 'react-router-dom'
import ShallowRenderer from 'react-test-renderer/shallow'

describe('ExplorePhotoGallery Component', () => {
const renderer = new ShallowRenderer()

const comp = (
<PureExplorePhotoGallery
Expand All @@ -16,7 +14,7 @@ describe('ExplorePhotoGallery Component', () => {

// shallow snapshot
it('should match snapshot', () => {
const tree = renderer.render(comp)
const tree = shallow(comp)
expect(tree).toMatchSnapshot()
})

Expand Down
119 changes: 119 additions & 0 deletions src/components/group/__test__/__snapshots__/group-nav.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`GroupNav Component should match snapshot 1`] = `
<div
className="pro_nav user_nav"
>
<ul>
<li>
<a
aria-current={false}
className="inst_nav"
href="/group/11"
onClick={[Function]}
>
Posts
</a>
</li>
<li>
<a
aria-current={false}
className="inst_nav"
href="/group/11/members"
onClick={[Function]}
>
Members
</a>
</li>
<li>
<a
aria-current={false}
className="inst_nav"
href="/group/11/gallery"
onClick={[Function]}
>
Gallery
</a>
</li>
<li>
<a
aria-current={false}
className="inst_nav"
href="/group/11/about"
onClick={[Function]}
>
About
</a>
</li>
</ul>
</div>
`;

exports[`GroupNav Component should match snapshot and show edit & add-member links also 1`] = `
<div
className="pro_nav user_nav"
>
<ul>
<li>
<a
aria-current={false}
className="inst_nav"
href="/group/11"
onClick={[Function]}
>
Posts
</a>
</li>
<li>
<a
aria-current={false}
className="inst_nav"
href="/group/11/members"
onClick={[Function]}
>
Members
</a>
</li>
<li>
<a
aria-current={false}
className="inst_nav"
href="/group/11/gallery"
onClick={[Function]}
>
Gallery
</a>
</li>
<li>
<a
aria-current={false}
className="inst_nav"
href="/group/11/edit"
onClick={[Function]}
>
Edit
</a>
</li>
<li>
<a
aria-current={false}
className="inst_nav"
href="/group/11/add-members"
onClick={[Function]}
>
Add members
</a>
</li>
<li>
<a
aria-current={false}
className="inst_nav"
href="/group/11/about"
onClick={[Function]}
>
About
</a>
</li>
</ul>
</div>
`;
Loading

0 comments on commit 80d22c3

Please sign in to comment.