Skip to content

Commit

Permalink
feat(): add sample files for auto-generated files
Browse files Browse the repository at this point in the history
[Delivers #29]
  • Loading branch information
Inumidun Amao committed Jun 13, 2017
1 parent fd3bc3d commit a2ffea8
Show file tree
Hide file tree
Showing 25 changed files with 316 additions and 4 deletions.
11 changes: 11 additions & 0 deletions example/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
"react",
"es2015",
"stage-2"
],
"plugins": [
"transform-object-rest-spread",
"transform-decorators-legacy"
]
}
8 changes: 4 additions & 4 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": "1.0.0",
"description": "m",
"main": "m",
"description": "React app",
"main": "index.js",
"scripts": {
"test": ""
},
"keywords": [],
"author": "a",
"license": "I",
"author": "emma",
"license": "MIT",
"dependencies": {
"axios": "^0.16.2",
"babel-cli": "^6.24.1",
Expand Down
File renamed without changes.
22 changes: 22 additions & 0 deletions sample/About.component.jsx.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';

/**
* About page view
* @class About
* @extends {React.Component}
*/
class About extends React.Component {

/**
* Renders the view of the component
* @returns {Object} react component to render
* @memberOf About
*/
render() {
return (
<h2>About page</h2>
);
}
}

export default About;
13 changes: 13 additions & 0 deletions sample/About.component.spec.js.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* global expect:true */
/* global shallow:true */

import React from 'react';//eslint-disable-line

import About from '../../src/components/static/About.component';

describe('<About />', () => {
it('should have a div', () => {
const wrapper = shallow(<About />);
expect(wrapper.find('div')).to.have.length(1);
});
});
27 changes: 27 additions & 0 deletions sample/Common.component.jsx.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';

/**
* Component to persist across all routes
* @class Common
* @extends {React.Component}
*/
class Common extends React.Component {

/**
* Renders the view of the component
* @returns {Object} react component to render
* @memberOf Common
*/
render() {
return (
<div>
<nav>
<h2>Navbar</h2>
</nav>
{this.props.children}
</div>
);
}
}

export default Common;
13 changes: 13 additions & 0 deletions sample/Common.component.spec.js.spac
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* global expect:true */
/* global shallow:true */

import React from 'react';//eslint-disable-line

import Common from '../../src/components/common/Common.component';

describe('<Common />', () => {
it('should have a Nav', () => {
const wrapper = shallow(<Common />);
expect(wrapper.find('nav')).to.have.length(1);
});
});
22 changes: 22 additions & 0 deletions sample/Home.component.jsx.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';

/**
* Home page view
* @class Home
* @extends {React.Component}
*/
class Home extends React.Component {

/**
* Renders the view of the component
* @returns {Object} react component to render
* @memberOf Home
*/
render() {
return (
<h2>Home page</h2>
);
}
}

export default Home;
16 changes: 16 additions & 0 deletions sample/Home.component.spec.js.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* global expect:true */
/* global shallow:true */
/* global mount:true */

import React from 'react';//eslint-disable-line

import Home from '../../src/components/Home.component';

describe('<Home />', () => {
it('should have a heading text', () => {
const wrapper = shallow(
<Home />
);
expect(wrapper.find('.heading')).to.have.length(1);
});
});
34 changes: 34 additions & 0 deletions sample/Routes.component.jsx.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { Router, Route, IndexRoute, browserHistory } from 'react-router';
import Common from './common/Common.component';
import Home from './Home.component';
import About from './static/About.component';

const routes = (
<Route path="/" component={Common}>
<IndexRoute component={Home} />
<Route path="/about" component={About} />
</Route>
);


/**
* Declare and define all routes in the application
* @class Routes
* @extends {React.Component}
*/
class Routes extends React.Component {

/**
* Renders the view of the component
* @returns {Object} react component to render
* @memberOf Routes
*/
render() {
return (
<Router history={browserHistory} routes={routes} />
);
}
}

export default Routes;
3 changes: 3 additions & 0 deletions sample/actionTypes.js.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {

}
7 changes: 7 additions & 0 deletions sample/actionTypes.spec.js.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import actionTypes from '../../src/actions/actionTypes';

describe('actionTypes', () => {
it('should return an object of actions', () => {
expect(actionTypes).to.be.an.object;
});
});
1 change: 1 addition & 0 deletions sample/e2e.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// write e2e tests here
45 changes: 45 additions & 0 deletions sample/helper.js.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import axios from 'axios';

/**
* Set the a value inside localStorage
* @export
* @param {String} key - key to store value with in localStorage
* @param {String} value - item to store inside localStorage
* @returns {Promise} returns a promise and resolves it with the stored value
*/
export function setLocalstorage(key, value) {
let storedValue;
return new Promise((resolve) => {
window.localStorage.setItem(key, value);
storedValue = window.localStorage.getItem(key);
if (storedValue) {
resolve(storedValue);
}
});
}

/**
* set a default header in axios
* @export
* @param {String} header - header name to set
* @param {String} value - value to set header as
* @returns {Void} does not have a return value
*/
export function setDefaultHeader(header, value) {
axios.defaults.headers.common.Authorization = value;
}


/**
* clear or remove one or all items from localStorage
* @export
* @param {String} key - item to remove in localStorage
* @returns {Void} does not have a return value
*/
export function clearStorage(key) {
if (!key) {
window.localStorage.clear();
} else {
window.localStorage.removeItem(key);
}
}
1 change: 1 addition & 0 deletions sample/image.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
All images will be stored in this folder
10 changes: 10 additions & 0 deletions sample/index.html.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>(title)</title>
</head>
<body>
<div id="app"></div>
<script src="/bundle.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions sample/index.jsx.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import ReactDom from 'react-dom';
import { Provider } from 'react-redux';
import store from './store';
import Routes from './components/Routes.component';

require('./sass/style.scss');
require('./sass/style.less');


ReactDom.render(
<Provider store={store}>
<Routes />
</Provider>,
document.getElementById('app')
);
44 changes: 44 additions & 0 deletions sample/mocha-helper.js.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { jsdom } from 'jsdom'; //eslint-disable-line
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import nock from 'nock';
import faker from 'faker';
import * as chai from 'chai';
import spies from 'chai-spies';
import sinon from 'sinon';
import moxios from 'moxios';
import { mount, shallow, render } from 'enzyme';

const exposedProperties = ['window', 'navigator', 'document'];

global.document = jsdom('');
global.window = document.defaultView;
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
exposedProperties.push(property);
global[property] = document.defaultView[property];
}
});

chai.use(spies);

global.window.localStorage = {
getItem: () => {
return 'abc';
}
}

global.sinon = sinon;
global.expect = chai.expect;
global.thunk = thunk;
global.configureMockStore = configureMockStore;
global.nock = nock;
global.mount = mount;
global.shallow = shallow;
global.render = render;
global.spy = spies;
global.faker = faker;
global.moxios = moxios;
global.navigator = {
userAgent: 'node.js'
};
8 changes: 8 additions & 0 deletions sample/root.reducer.js.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { combineReducers } from 'redux';
import reduceReducers from 'reduce-reducers';

const combinedReducers = combineReducers({

});

export default reduceReducers(combinedReducers);
3 changes: 3 additions & 0 deletions sample/root.reducer.spec.js.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
describe('Root Reducer', () => {

});
1 change: 1 addition & 0 deletions sample/script.js.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This is a custom javascript file
11 changes: 11 additions & 0 deletions sample/store.js.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { applyMiddleware, createStore, compose } from 'redux';
import thunk from 'redux-thunk';
import reducers from './reducers/root.reducer';

const middleware = [thunk];

const finalCreateStore = compose(
applyMiddleware(...middleware)
)(createStore);

export default finalCreateStore(reducers);
3 changes: 3 additions & 0 deletions sample/style.css.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
margin: auto;
}
1 change: 1 addition & 0 deletions sample/vendor.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
All vendors will be placed in this directory

0 comments on commit a2ffea8

Please sign in to comment.