Skip to content

Commit

Permalink
feature(requests-table):Implement requests table [Finishes #171380698]
Browse files Browse the repository at this point in the history
  • Loading branch information
the22mastermind committed Jun 11, 2020
1 parent 8c78fbd commit 4a2c297
Show file tree
Hide file tree
Showing 42 changed files with 1,315 additions and 137 deletions.
12 changes: 10 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"presets": ["@babel/preset-env","@babel/preset-react"],
"plugins": ["transform-class-properties"]
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"transform-class-properties",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-regenerator",
"@babel/plugin-transform-runtime"
]
}
7 changes: 7 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "2"
checks:
method-lines:
config:
threshold: 40
exclude_patterns:
- "**/__tests__/"
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
}
],
"react/no-array-index-key": 0,
"jsx-a11y/anchor-is-valid": 0
"jsx-a11y/anchor-is-valid": 0,
"arrow-body-style": 0,
"no-shadow": 0,
"no-nested-ternary": 0,
"react/jsx-props-no-spreading": 0
}
}
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@
"homepage": "https://github.com/Stackup-Rwanda/stackup2-barefoot-frontend#readme",
"dependencies": {
"@babel/core": "^7.9.6",
"@babel/plugin-transform-runtime": "^7.10.1",
"@babel/polyfill": "^7.10.1",
"@babel/preset-env": "^7.10.2",
"@babel/preset-react": "^7.9.4",
"@material-ui/core": "^4.10.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.55",
"@storybook/addon-actions": "^5.3.18",
"@storybook/addon-links": "^5.3.18",
"@storybook/addons": "^5.3.18",
"@storybook/react": "^5.3.18",
"@testing-library/react": "^10.0.4",
"axios": "^0.19.2",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.0.1",
"babel-loader": "^8.1.0",
Expand All @@ -59,23 +64,28 @@
"jest": "^26.0.1",
"jest-html-reporters": "^1.2.1",
"jest-transform-stub": "^2.0.0",
"less-loader": "^6.1.0",
"mini-css-extract-plugin": "^0.9.0",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-loader-spinner": "^3.1.14",
"react-redux": "^7.2.0",
"react-router-dom": "^5.2.0",
"react-slick": "^0.26.1",
"react-test-renderer": "^16.13.1",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-mock-store": "^1.5.4",
"redux-thunk": "^2.3.0",
"slick-carousel": "^1.8.1",
"style-loader": "^1.2.1",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.11.0"
},
"devDependencies": {
"dotenv-webpack": "^1.8.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-plugin-import": "^2.20.2",
Expand Down
51 changes: 29 additions & 22 deletions src/__tests__/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,39 @@ import { mount, shallow } from 'enzyme';
import React from 'react';
import { Provider } from 'react-redux';
import renderer from 'react-test-renderer';
import { cleanup } from '@testing-library/react';
import configureStore from 'redux-mock-store';
import App from '../entry/App';
import LandingPage from '../views/LandingPage/LandingPage';
import reducer from '../reducers/reducer';
import firstMessage from '../actions/actions';
// import LandingPage from '../views/LandingPage/LandingPage';
// import reducer from '../reducers/reducer';
// import firstMessage from '../actions/actions';

const mockStore = configureStore([]);
const store = mockStore({
message: 'Welcome',
});
store.dispatch = jest.fn();
const component = renderer.create(
<Provider store={store}>
<LandingPage />
</Provider>,
);
// const mockStore = configureStore([]);
// const store = mockStore({
// message: 'Welcome',
// });
// store.dispatch = jest.fn();
// const component = renderer.create(
// <Provider store={store}>
// <LandingPage />
// </Provider>,
// );
describe('App tests', () => {
it('Will prove that the app is rendered from App component', () => {
const appRender = shallow(<App />);
expect(appRender.contains(<LandingPage />));
});
afterEach(cleanup);

it('should return welcome when no action provided', () => {
expect(reducer(undefined, {})).toEqual({ message: 'Welcome' });
});
it('should return Redux when action is provided with value', () => {
expect(reducer(undefined, { ...firstMessage, value: 'Redux' })).toEqual({ message: 'Redux' });
it('Should match the App component snapshot', () => {
const tree = renderer.create(<App />).toJSON();
expect(tree).toMatchSnapshot();
});
// it('Will prove that the app is rendered from App component', () => {
// const appRender = shallow(<App />);
// expect(appRender.contains(<LandingPage />));
// });

// it('should return welcome when no action provided', () => {
// expect(reducer(undefined, {})).toEqual({ message: 'Welcome' });
// });
// it('should return Redux when action is provided with value', () => {
// expect(reducer(undefined, { ...firstMessage, value: 'Redux' })).toEqual({ message: 'Redux' });
// });
});
62 changes: 62 additions & 0 deletions src/__tests__/RequestsTablePage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* eslint-disable no-undef */
import React from 'react';
import { mount } from 'enzyme';
import { cleanup } from '@testing-library/react';
import thunk from 'redux-thunk';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import { BrowserRouter as Router } from 'react-router-dom';
import RequestsTablePage from '../views/RequestsTablePage/RequestsTablePage';
import requests from './data/data';

const mockStore = configureStore([]);
const store = mockStore(
{
loading: true,
tripRequests: [],
error: '',
},
);
store.dispatch = jest.fn();

const fetchTripRequests = jest.fn();
const props = {
requests,
fetchTripRequests,
};

describe('<RequestsTablePage/>', () => {
afterEach(cleanup);
it('Should return true if the RequestsTablePage component exists', () => {
const tree = mount(
<Provider store={store}>
<Router>
<RequestsTablePage {...props} />
</Router>
</Provider>,
);
expect(tree.find('Card').exists()).toBe(true);
});

it('Should render props for the RequestsTablePage component', () => {
const tree = mount(
<Provider store={store}>
<Router>
<RequestsTablePage {...props} />
</Router>
</Provider>,
);
expect(tree.find('StyledTableCell').exists()).toBe(true);
});

it('Should match the RequestsTablePage snapshot', () => {
const tree = mount(
<Provider store={store}>
<Router>
<RequestsTablePage {...props} />
</Router>
</Provider>,
);
expect(tree).toMatchSnapshot();
});
});
12 changes: 12 additions & 0 deletions src/__tests__/SectionHeader.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { cleanup } from '@testing-library/react';
import SectionHeader from '../components/SectionHeader/SectionHeader';

describe('<SectionHeader/>', () => {
afterEach(cleanup);
it('Should match the SectionHeader component snapshot', () => {
const tree = renderer.create(<SectionHeader />).toJSON();
expect(tree).toMatchSnapshot();
});
});
50 changes: 0 additions & 50 deletions src/__tests__/__snapshots__/NavBar.test.js.snap

This file was deleted.

7 changes: 7 additions & 0 deletions src/__tests__/__snapshots__/SectionHeader.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<SectionHeader/> Should match the SectionHeader component snapshot 1`] = `
<p
className="MuiTypography-root makeStyles-title-1 MuiTypography-body1"
/>
`;
32 changes: 32 additions & 0 deletions src/__tests__/data/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const requests = {
tripRequests: [
{
id: 1,
trips: [
{
travelDate: '2020-09-15',
travelFrom: 'Kigali',
travelTo: 'Durban',
},
],
travelReason: 'Africa Tech Summit',
accommodation: true,
status: 'pending',
},
{
id: 2,
trips: [
{
travelDate: '2020-09-10',
travelFrom: 'Kigali',
travelTo: 'Dubai',
},
],
travelReason: 'Africa Tech Summit',
accommodation: true,
status: 'pending',
},
],
};

export default requests;
5 changes: 0 additions & 5 deletions src/actions/actions.js

This file was deleted.

6 changes: 5 additions & 1 deletion src/assets/styles/sass/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ body {
}

.testimony-item {
display: flex;
display: flex !important;
flex-direction: row;
justify-content: center;
align-items: center;
Expand Down Expand Up @@ -169,6 +169,10 @@ body {
font-size: 14pt;
}

.testimony-description {
margin-left: 2px;
}

.testimony-author {
font-size: 10pt;
}
Expand Down
Loading

0 comments on commit 4a2c297

Please sign in to comment.