Skip to content

Commit

Permalink
(new build) create build and test for the first method
Browse files Browse the repository at this point in the history
  • Loading branch information
gtkatakura committed Jul 24, 2017
1 parent 72c3773 commit b34304b
Show file tree
Hide file tree
Showing 10 changed files with 2,729 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["env"]
}
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "airbnb"
"extends": "airbnb",
"env": {
"mocha": true
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
21 changes: 18 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
{
"name": "remram",
"version": "1.0.0",
"main": "index.js",
"main": "dist/index.js",
"repository": "https://github.com/gtkatakura/remram.git",
"author": "gtkatakura <gt.katakura@gmail.com>",
"license": "MIT",
"scripts": {
"build": "webpack",
"test": "npm run coverage",
"test:all": "mocha --compilers js:babel-core/register test/**/*.spec.js",
"coverage": "nyc -r=lcov -r=text -i babel-core/register mocha test/**/*.spec.js"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-preset-env": "^1.6.0",
"chai": "^4.1.0",
"eslint": "3.19.0",
"eslint-config-airbnb": "^15.0.2",
"eslint-plugin-import": "2.6.1",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "7.1.0"
}
"eslint-plugin-react": "7.1.0",
"mocha": "^3.4.2",
"nyc": "^11.0.3",
"webpack": "^3.3.0"
},
"dependencies": {}
}
3 changes: 3 additions & 0 deletions src/array/flatten.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const flatten = array => [].concat(...array);

export default flatten;
5 changes: 5 additions & 0 deletions src/array/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import flatten from './flatten';

export default {
flatten,
};
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import array from './array';

export default array;
33 changes: 33 additions & 0 deletions test/array/flatten.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect } from 'chai';
import _ from '../../src';

const { flatten } = _;

describe('flatten', () => {
describe('when is a empty array', () => {
it('should return a empty array', () => {
expect(flatten([])).to.eql([]);
});
});

describe('when is a linear array', () => {
it('should return a linear array', () => {
const result = flatten([1, 2, 3]);
expect(result).to.eql([1, 2, 3]);
});
});

describe('when is a array with one level', () => {
it('should return a linear array', () => {
const result = flatten([[1, 2, 3]]);
expect(result).to.eql([1, 2, 3]);
});
});

describe('when is a array with two levels', () => {
it('should return a array with one level', () => {
const result = flatten([[[1, 2, 3]]]);
expect(result).to.eql([[1, 2, 3]]);
});
});
});
16 changes: 16 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const path = require('path');

module.exports = {
entry: './src/index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
},
module: {
loaders: [{
test: /.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
}],
},
};
Loading

0 comments on commit b34304b

Please sign in to comment.