Merge pull request #238 from jshjohnson/feature/mocha-and-chai
Feature/mocha and chai
13
.eslintrc
|
@ -9,6 +9,19 @@
|
||||||
"mocha": true,
|
"mocha": true,
|
||||||
"jasmine": true
|
"jasmine": true
|
||||||
},
|
},
|
||||||
|
"globals": {
|
||||||
|
"__DEV__": true,
|
||||||
|
"describe": true,
|
||||||
|
"it": true,
|
||||||
|
"before": true,
|
||||||
|
"after": true,
|
||||||
|
"beforeEach": true,
|
||||||
|
"afterEach": true,
|
||||||
|
"expect": true,
|
||||||
|
"browser": true,
|
||||||
|
"by": true,
|
||||||
|
"element": true
|
||||||
|
},
|
||||||
"parser": "babel-eslint",
|
"parser": "babel-eslint",
|
||||||
"rules": {
|
"rules": {
|
||||||
"strict": 0,
|
"strict": 0,
|
||||||
|
|
2
.gitignore
vendored
|
@ -9,3 +9,5 @@ package-lock.json
|
||||||
# Test
|
# Test
|
||||||
tests/reports
|
tests/reports
|
||||||
tests/results
|
tests/results
|
||||||
|
.nyc_output
|
||||||
|
coverage
|
||||||
|
|
49
config/test.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
const { JSDOM } = require('jsdom');
|
||||||
|
|
||||||
|
const jsdom = new JSDOM('<!doctype html><html><body></body></html>');
|
||||||
|
const { window } = jsdom;
|
||||||
|
|
||||||
|
function copyProps(src, target) {
|
||||||
|
const props = Object.getOwnPropertyNames(src)
|
||||||
|
.filter(prop => typeof target[prop] === 'undefined')
|
||||||
|
.map(prop => Object.getOwnPropertyDescriptor(src, prop));
|
||||||
|
Object.defineProperties(target, props);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ignoreExtensions(extensions = [], returnValue = {}) {
|
||||||
|
function noop() {
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions.forEach((ext) => {
|
||||||
|
require.extensions[ext] = noop;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function mockStorage() {
|
||||||
|
return {
|
||||||
|
removeItem: function(key) {
|
||||||
|
delete this[key];
|
||||||
|
},
|
||||||
|
getItem: function(key) {
|
||||||
|
return this[key];
|
||||||
|
},
|
||||||
|
setItem: function(key, value) {
|
||||||
|
this[key] = value;
|
||||||
|
},
|
||||||
|
clear: function() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
global.window = window;
|
||||||
|
global.document = window.document;
|
||||||
|
global.navigator = {
|
||||||
|
userAgent: 'node.js'
|
||||||
|
};
|
||||||
|
global.HTMLElement = window.HTMLElement;
|
||||||
|
global.window.localStorage = mockStorage;
|
||||||
|
global.window.sessionStorage = mockStorage;
|
||||||
|
|
||||||
|
copyProps(window, global);
|
||||||
|
ignoreExtensions(['.scss', '.css']);
|
||||||
|
ignoreExtensions(['.jpg', '.png', '.svg'], '');
|
30
package.json
|
@ -2,18 +2,20 @@
|
||||||
"name": "choices.js",
|
"name": "choices.js",
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"description": "A vanilla JS customisable text input/select box plugin",
|
"description": "A vanilla JS customisable text input/select box plugin",
|
||||||
"main": "./assets/scripts/dist/choices.min.js",
|
"main": "./src/scripts/dist/choices.min.js",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server.js",
|
"start": "node server.js",
|
||||||
"lint": "eslint assets/**/*.js",
|
"lint": "eslint assets/**/*.js",
|
||||||
"test": "karma start --single-run --no-auto-watch tests/karma.config.js",
|
"test": "karma start --single-run --no-auto-watch tests/karma.config.js",
|
||||||
"test:watch": "karma start --auto-watch --no-single-run tests/karma.config.js",
|
"test:watch": "karma start --auto-watch --no-single-run tests/karma.config.js",
|
||||||
|
"test:mocha": "nyc mocha --require ./config/test.js --compilers babel-core/register \"./src/**/**/**/**/*.spec.js\"",
|
||||||
|
"test:mocha:watch": "npm run test:mocha -- --watch",
|
||||||
"css:watch": "nodemon -e scss -x \"npm run css:build\"",
|
"css:watch": "nodemon -e scss -x \"npm run css:build\"",
|
||||||
"css:build": "npm run css:sass -s && npm run css:prefix -s && npm run css:min -s",
|
"css:build": "npm run css:sass -s && npm run css:prefix -s && npm run css:min -s",
|
||||||
"css:sass": "node-sass --output-style expanded --include-path scss assets/styles/scss/base.scss assets/styles/css/base.css && node-sass --output-style expanded --include-path scss assets/styles/scss/choices.scss assets/styles/css/choices.css",
|
"css:sass": "node-sass --output-style expanded --include-path scss src/styles/scss/base.scss src/styles/css/base.css && node-sass --output-style expanded --include-path scss src/styles/scss/choices.scss src/styles/css/choices.css",
|
||||||
"css:prefix": "postcss --use autoprefixer -b 'last 2 versions' assets/styles/css/*.css -d assets/styles/css/",
|
"css:prefix": "postcss --use autoprefixer -b 'last 2 versions' src/styles/css/*.css -d src/styles/css/",
|
||||||
"css:min": "csso assets/styles/css/base.css assets/styles/css/base.min.css && csso assets/styles/css/choices.css assets/styles/css/choices.min.css",
|
"css:min": "csso src/styles/css/base.css src/styles/css/base.min.css && csso src/styles/css/choices.css src/styles/css/choices.min.css",
|
||||||
"js:build": "concurrently --prefix-colors yellow,green \"webpack --minimize --config webpack.config.prod.js\" \"webpack --config webpack.config.prod.js\"",
|
"js:build": "concurrently --prefix-colors yellow,green \"webpack --minimize --config webpack.config.prod.js\" \"webpack --config webpack.config.prod.js\"",
|
||||||
"version": "node version.js --current $npm_package_version --new $npm_config_newVersion",
|
"version": "node version.js --current $npm_package_version --new $npm_config_newVersion",
|
||||||
"postversion": "npm run js:build",
|
"postversion": "npm run js:build",
|
||||||
|
@ -31,13 +33,15 @@
|
||||||
"homepage": "https://github.com/jshjohnson/Choices#readme",
|
"homepage": "https://github.com/jshjohnson/Choices#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"autoprefixer": "^6.3.3",
|
"autoprefixer": "^6.3.3",
|
||||||
"babel-core": "^6.7.2",
|
"babel-core": "^6.25.0",
|
||||||
"babel-eslint": "^7.2.3",
|
"babel-eslint": "^7.2.3",
|
||||||
"babel-loader": "^6.2.4",
|
"babel-loader": "^6.2.4",
|
||||||
"babel-preset-es2015": "^6.6.0",
|
"babel-preset-es2015": "^6.6.0",
|
||||||
|
"chai": "^4.1.0",
|
||||||
"concurrently": "^3.1.0",
|
"concurrently": "^3.1.0",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
"csso": "^1.8.2",
|
"csso": "^1.8.2",
|
||||||
|
"custom-event-autopolyfill": "^0.1.3",
|
||||||
"es6-promise": "^3.2.1",
|
"es6-promise": "^3.2.1",
|
||||||
"eslint": "^3.19.0",
|
"eslint": "^3.19.0",
|
||||||
"eslint-config-airbnb": "^15.1.0",
|
"eslint-config-airbnb": "^15.1.0",
|
||||||
|
@ -46,6 +50,7 @@
|
||||||
"eslint-plugin-jsx-a11y": "^5.1.1",
|
"eslint-plugin-jsx-a11y": "^5.1.1",
|
||||||
"eslint-plugin-react": "^7.2.1",
|
"eslint-plugin-react": "^7.2.1",
|
||||||
"jasmine-core": "2.4.1",
|
"jasmine-core": "2.4.1",
|
||||||
|
"jsdom": "^11.1.0",
|
||||||
"karma": "^1.1.0",
|
"karma": "^1.1.0",
|
||||||
"karma-coverage": "^1.0.0",
|
"karma-coverage": "^1.0.0",
|
||||||
"karma-es6-shim": "^1.0.0",
|
"karma-es6-shim": "^1.0.0",
|
||||||
|
@ -54,10 +59,13 @@
|
||||||
"karma-phantomjs-launcher": "^1.0.1",
|
"karma-phantomjs-launcher": "^1.0.1",
|
||||||
"karma-spec-reporter": "0.0.26",
|
"karma-spec-reporter": "0.0.26",
|
||||||
"karma-webpack": "^1.7.0",
|
"karma-webpack": "^1.7.0",
|
||||||
|
"mocha": "^3.4.2",
|
||||||
"node-sass": "^3.4.2",
|
"node-sass": "^3.4.2",
|
||||||
"nodemon": "^1.9.1",
|
"nodemon": "^1.9.1",
|
||||||
|
"nyc": "^11.0.3",
|
||||||
"opn-cli": "^3.1.0",
|
"opn-cli": "^3.1.0",
|
||||||
"postcss-cli": "^2.5.1",
|
"postcss-cli": "^2.5.1",
|
||||||
|
"sinon": "^2.4.0",
|
||||||
"webpack": "^1.12.14",
|
"webpack": "^1.12.14",
|
||||||
"webpack-dashboard": "^0.1.8",
|
"webpack-dashboard": "^0.1.8",
|
||||||
"webpack-dev-server": "^1.14.1",
|
"webpack-dev-server": "^1.14.1",
|
||||||
|
@ -72,12 +80,20 @@
|
||||||
"npmName": "choices.js",
|
"npmName": "choices.js",
|
||||||
"npmFileMap": [
|
"npmFileMap": [
|
||||||
{
|
{
|
||||||
"basePath": "assets",
|
"basePath": "src",
|
||||||
"files": [
|
"files": [
|
||||||
"scripts/dist/*",
|
"scripts/dist/*",
|
||||||
"styles/css/*",
|
"styles/css/*",
|
||||||
"icons/*"
|
"icons/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"nyc": {
|
||||||
|
"include": [
|
||||||
|
"src/**/**/**/**/**/*.js"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"src/**/**/**/**/**/*.spec.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 244 B After Width: | Height: | Size: 244 B |
Before Width: | Height: | Size: 244 B After Width: | Height: | Size: 244 B |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 574 B After Width: | Height: | Size: 574 B |
Before Width: | Height: | Size: 887 B After Width: | Height: | Size: 887 B |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 6 KiB After Width: | Height: | Size: 6 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
1
src/scripts/dist/choices.min.js.map
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"file":"choices.min.js","sources":[],"mappings":";;;","sourceRoot":""}
|
|
@ -1,6 +1,6 @@
|
||||||
import Fuse from 'fuse.js';
|
import Fuse from 'fuse.js';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import Store from './store/index';
|
import Store from './store/store';
|
||||||
import Dropdown from './components/dropdown';
|
import Dropdown from './components/dropdown';
|
||||||
import Container from './components/container';
|
import Container from './components/container';
|
||||||
import Input from './components/input';
|
import Input from './components/input';
|
||||||
|
@ -15,7 +15,7 @@ import {
|
||||||
addGroup,
|
addGroup,
|
||||||
clearAll,
|
clearAll,
|
||||||
clearChoices,
|
clearChoices,
|
||||||
} from './actions/index';
|
} from './actions/actions';
|
||||||
import {
|
import {
|
||||||
isScrolledIntoView,
|
isScrolledIntoView,
|
||||||
getAdjacentEl,
|
getAdjacentEl,
|
1190
src/scripts/src/choices.spec.js
Normal file
0
src/scripts/src/store/store.spec.js
Normal file
|
@ -2,13 +2,13 @@ import 'whatwg-fetch';
|
||||||
import 'es6-promise';
|
import 'es6-promise';
|
||||||
import 'core-js/fn/object/assign';
|
import 'core-js/fn/object/assign';
|
||||||
import 'core-js/fn/array/includes';
|
import 'core-js/fn/array/includes';
|
||||||
import Choices from '../../assets/scripts/src/choices';
|
import Choices from '../../src/scripts/src/choices.js';
|
||||||
import itemReducer from '../../assets/scripts/src/reducers/items';
|
import itemReducer from '../../src/scripts/src/reducers/items.js';
|
||||||
import choiceReducer from '../../assets/scripts/src/reducers/choices';
|
import choiceReducer from '../../src/scripts/src/reducers/choices.js';
|
||||||
import {
|
import {
|
||||||
addItem as addItemAction,
|
addItem as addItemAction,
|
||||||
addChoice as addChoiceAction,
|
addChoice as addChoiceAction,
|
||||||
} from '../../assets/scripts/src/actions/index';
|
} from '../../assets/scripts/src/actions/actions';
|
||||||
|
|
||||||
describe('Choices', () => {
|
describe('Choices', () => {
|
||||||
describe('should initialize Choices', () => {
|
describe('should initialize Choices', () => {
|
||||||
|
|
|
@ -8,12 +8,12 @@ module.exports = {
|
||||||
devtool: 'eval',
|
devtool: 'eval',
|
||||||
entry: [
|
entry: [
|
||||||
'webpack-dev-server/client?http://localhost:3000',
|
'webpack-dev-server/client?http://localhost:3000',
|
||||||
'./assets/scripts/src/choices'
|
'./src/scripts/src/choices'
|
||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, 'dist'),
|
path: path.join(__dirname, 'dist'),
|
||||||
filename: 'choices.min.js',
|
filename: 'choices.min.js',
|
||||||
publicPath: '/assets/scripts/dist/',
|
publicPath: '/src/scripts/dist/',
|
||||||
library: 'Choices',
|
library: 'Choices',
|
||||||
libraryTarget: 'umd',
|
libraryTarget: 'umd',
|
||||||
},
|
},
|
||||||
|
@ -34,7 +34,7 @@ module.exports = {
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
exclude: /(node_modules|bower_components)/,
|
exclude: /(node_modules|bower_components)/,
|
||||||
loaders: ['babel', 'eslint-loader'],
|
loaders: ['babel', 'eslint-loader'],
|
||||||
include: path.join(__dirname, 'assets/scripts/src')
|
include: path.join(__dirname, 'src/scripts/src')
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,12 +8,12 @@ const minimize = process.argv.includes('--minimize');
|
||||||
const config = {
|
const config = {
|
||||||
devtool: minimize ? false : 'cheap-module-source-map',
|
devtool: minimize ? false : 'cheap-module-source-map',
|
||||||
entry: [
|
entry: [
|
||||||
'./assets/scripts/src/choices'
|
'./src/scripts/src/choices'
|
||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, '/assets/scripts/dist'),
|
path: path.join(__dirname, '/src/scripts/dist'),
|
||||||
filename: minimize ? 'choices.min.js' : 'choices.js',
|
filename: minimize ? 'choices.min.js' : 'choices.js',
|
||||||
publicPath: '/assets/scripts/dist/',
|
publicPath: '/src/scripts/dist/',
|
||||||
library: 'Choices',
|
library: 'Choices',
|
||||||
libraryTarget: 'umd',
|
libraryTarget: 'umd',
|
||||||
},
|
},
|
||||||
|
@ -34,7 +34,7 @@ const config = {
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
exclude: /(node_modules|bower_components)/,
|
exclude: /(node_modules|bower_components)/,
|
||||||
loaders: ['babel'],
|
loaders: ['babel'],
|
||||||
include: path.join(__dirname, 'assets/scripts/src')
|
include: path.join(__dirname, 'src/scripts/src')
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|