From 56be88ed41b73fe4d0d7be18f471e7f3719fd2e8 Mon Sep 17 00:00:00 2001 From: Etienne Lemay Date: Wed, 8 Nov 2017 22:41:57 -0800 Subject: [PATCH] Move spec out of src --- .gitignore | 4 +++- .npmignore | 1 + karma.conf.js | 6 +++--- package.json | 10 ++++----- .../emoji-index-spec.js | 6 ++++-- .../pickerSpec.js => spec/picker-spec.js | 12 +++++------ {src => spec}/webpack.config.js | 21 +++---------------- 7 files changed, 25 insertions(+), 35 deletions(-) rename src/utils/emoji-indexSpec.js => spec/emoji-index-spec.js (88%) rename src/components/pickerSpec.js => spec/picker-spec.js (79%) rename {src => spec}/webpack.config.js (71%) diff --git a/.gitignore b/.gitignore index aa5572e..68264dc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ node_modules/ dist/ dist-es/ bundle.js -/src/data/data.js \ No newline at end of file +stats.json +report.html +/src/data/data.js diff --git a/.npmignore b/.npmignore index d1dbf18..1d8ccc7 100644 --- a/.npmignore +++ b/.npmignore @@ -3,6 +3,7 @@ scripts/ .* src/ +spec/ example/ karma.conf.js yarn.lock diff --git a/karma.conf.js b/karma.conf.js index 2fc6177..6a71ce8 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,6 +1,6 @@ // Karma configuration // Generated on Fri Jan 27 2017 13:33:03 GMT-0700 (MST) -var webpackConfig = require('./src/webpack.config.js'); +var webpackConfig = require('./spec/webpack.config.js'); module.exports = function(config) { config.set({ @@ -16,7 +16,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'src/**/*Spec.js', + 'spec/*spec.js', ], @@ -28,7 +28,7 @@ module.exports = function(config) { // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - 'src/**/*Spec.js': ['webpack'], + 'spec/*spec.js': ['webpack'], }, diff --git a/package.json b/package.json index d7b7f86..3c7f86b 100644 --- a/package.json +++ b/package.json @@ -64,12 +64,12 @@ "clean": "rm -rf dist/ dist-es/ src/data/data.js", "build:data": "node scripts/build-data", "build:dist": "npm run build:cjs && npm run build:es", - "build:cjs": "BABEL_ENV=cjs babel src --out-dir dist --copy-files --ignore webpack.config.js", - "build:es": "babel src --out-dir dist-es --copy-files --ignore webpack.config.js", + "build:cjs": "BABEL_ENV=cjs babel src --out-dir dist --copy-files", + "build:es": "babel src --out-dir dist-es --copy-files", "build": "npm run clean && npm run build:data && npm run build:dist", - "watch": "BABEL_ENV=cjs babel src --watch --out-dir dist --copy-files --ignore webpack.config.js", + "watch": "BABEL_ENV=cjs babel src --watch --out-dir dist --copy-files", "start": "npm run watch", - "stats": "webpack --config ./src/webpack.config.js --json > stats.json", + "stats": "webpack --config ./spec/webpack.config.js --json > spec/stats.json", "react:clean": "rimraf node_modules/{react,react-dom,react-addons-test-utils}", "react:14": "npm run react:clean && npm i react@^0.14 react-dom@^0.14 react-addons-test-utils@^0.14 --save-dev", "react:15": "npm run react:clean && npm i react@^15 react-dom@^15 react-addons-test-utils@^15 --save-dev", @@ -77,7 +77,7 @@ "prepublish": "npm run build", "storybook": "start-storybook -p 6006", "build-storybook": "build-storybook", - "prettier": "prettier --no-semi --single-quote --trailing-comma es5 --write \"src/**/*.js\"" + "prettier": "prettier --no-semi --single-quote --trailing-comma es5 --write \"{src,spec}/**/*.js\"" }, "size-limit": [ { diff --git a/src/utils/emoji-indexSpec.js b/spec/emoji-index-spec.js similarity index 88% rename from src/utils/emoji-indexSpec.js rename to spec/emoji-index-spec.js index fc80484..78c6771 100644 --- a/src/utils/emoji-indexSpec.js +++ b/spec/emoji-index-spec.js @@ -1,4 +1,4 @@ -import emojiIndex from './emoji-index' +import emojiIndex from '../src/utils/emoji-index' describe('#emojiIndex', () => { describe('search', function() { @@ -17,7 +17,9 @@ describe('#emojiIndex', () => { }) it('should filter only emojis we care about, exclude pineapple', () => { - let emojisToShowFilter = (data) => { data.unified !== '1F34D' } + let emojisToShowFilter = data => { + data.unified !== '1F34D' + } expect( emojiIndex.search('apple', { emojisToShowFilter }).map(obj => obj.id) ).not.toContain('pineapple') diff --git a/src/components/pickerSpec.js b/spec/picker-spec.js similarity index 79% rename from src/components/pickerSpec.js rename to spec/picker-spec.js index 38a1a89..7ae20fc 100644 --- a/src/components/pickerSpec.js +++ b/spec/picker-spec.js @@ -1,6 +1,6 @@ import React from 'react' import TestUtils from 'react-dom/test-utils' -import Picker from './picker' +import Picker from '../src/components/picker' const { click } = TestUtils.Simulate @@ -10,6 +10,11 @@ const { findRenderedComponentWithType, } = TestUtils +const render = (props = {}) => { + const defaultProps = {} + return renderIntoDocument() +} + describe('Picker', () => { let subject @@ -29,9 +34,4 @@ describe('Picker', () => { expect(subject.categories.length).toEqual(2) }) }) - - function render(props = {}) { - const defaultProps = {} - return renderIntoDocument() - } }) diff --git a/src/webpack.config.js b/spec/webpack.config.js similarity index 71% rename from src/webpack.config.js rename to spec/webpack.config.js index 6ae4b18..59d4cfe 100644 --- a/src/webpack.config.js +++ b/spec/webpack.config.js @@ -10,8 +10,8 @@ var TEST = process.env.NODE_ENV === 'test' var config = { entry: path.resolve('src/index.js'), output: { - path: path.resolve('dist'), - filename: 'emoji-mart.js', + path: path.resolve('spec'), + filename: 'bundle.js', library: 'EmojiMart', libraryTarget: 'umd', }, @@ -23,22 +23,7 @@ var config = { { test: /\.js$/, use: 'babel-loader', - include: [path.resolve('src'), path.resolve('data')], - }, - { - test: /\.svg$/, - use: [ - { - loader: 'babel-loader', - }, - { - loader: 'svg-jsx-loader', - options: { - es6: true, - }, - }, - ], - include: [path.resolve('src/svgs')], + include: [path.resolve('src'), path.resolve('spec')], }, ], },