Begun mocha/chai setup

This commit is contained in:
Josh Johnson 2017-07-24 15:18:43 +01:00
parent 753f163195
commit 241c9e5dcc
42 changed files with 1274 additions and 20 deletions

View file

@ -9,6 +9,19 @@
"mocha": 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",
"rules": {
"strict": 0,

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{}

49
config/test.js Normal file
View 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'], '');

View file

@ -2,18 +2,19 @@
"name": "choices.js",
"version": "3.0.2",
"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",
"scripts": {
"start": "node server.js",
"lint": "eslint assets/**/*.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:mocha": "nyc mocha --require ./config/test.js --compilers babel-core/register \"./src/**/**/**/**/*.spec.js\"",
"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: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:prefix": "postcss --use autoprefixer -b 'last 2 versions' assets/styles/css/*.css -d assets/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: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' src/styles/css/*.css -d src/styles/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\"",
"version": "node version.js --current $npm_package_version --new $npm_config_newVersion",
"postversion": "npm run js:build",
@ -31,10 +32,11 @@
"homepage": "https://github.com/jshjohnson/Choices#readme",
"devDependencies": {
"autoprefixer": "^6.3.3",
"babel-core": "^6.7.2",
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"chai": "^4.1.0",
"concurrently": "^3.1.0",
"core-js": "^2.4.1",
"csso": "^1.8.2",
@ -46,6 +48,7 @@
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.2.1",
"jasmine-core": "2.4.1",
"jsdom": "^11.1.0",
"karma": "^1.1.0",
"karma-coverage": "^1.0.0",
"karma-es6-shim": "^1.0.0",
@ -54,8 +57,10 @@
"karma-phantomjs-launcher": "^1.0.1",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "^1.7.0",
"mocha": "^3.4.2",
"node-sass": "^3.4.2",
"nodemon": "^1.9.1",
"nyc": "^11.0.3",
"opn-cli": "^3.1.0",
"postcss-cli": "^2.5.1",
"webpack": "^1.12.14",
@ -72,12 +77,20 @@
"npmName": "choices.js",
"npmFileMap": [
{
"basePath": "assets",
"basePath": "src",
"files": [
"scripts/dist/*",
"styles/css/*",
"icons/*"
]
}
]
],
"nyc": {
"include": [
"src/**/**/**/**/**/*.js"
],
"exclude": [
"src/**/**/**/**/**/*.spec.js"
]
}
}

View file

Before

Width:  |  Height:  |  Size: 244 B

After

Width:  |  Height:  |  Size: 244 B

View file

Before

Width:  |  Height:  |  Size: 244 B

After

Width:  |  Height:  |  Size: 244 B

View file

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 574 B

View file

Before

Width:  |  Height:  |  Size: 887 B

After

Width:  |  Height:  |  Size: 887 B

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 6 KiB

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

View file

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
View file

@ -0,0 +1 @@
{"version":3,"file":"choices.min.js","sources":[],"mappings":";;;","sourceRoot":""}

View file

@ -1,6 +1,6 @@
import Fuse from 'fuse.js';
import classNames from 'classnames';
import Store from './store/index';
import Store from './store/store';
import Dropdown from './components/dropdown';
import Container from './components/container';
import Input from './components/input';
@ -15,7 +15,7 @@ import {
addGroup,
clearAll,
clearChoices,
} from './actions/index';
} from './actions/actions';
import {
isScrolledIntoView,
getAdjacentEl,

File diff suppressed because it is too large Load diff

View file

View file

@ -2,13 +2,13 @@ import 'whatwg-fetch';
import 'es6-promise';
import 'core-js/fn/object/assign';
import 'core-js/fn/array/includes';
import Choices from '../../assets/scripts/src/choices';
import itemReducer from '../../assets/scripts/src/reducers/items';
import choiceReducer from '../../assets/scripts/src/reducers/choices';
import Choices from '../../src/scripts/src/choices.js';
import itemReducer from '../../src/scripts/src/reducers/items.js';
import choiceReducer from '../../src/scripts/src/reducers/choices.js';
import {
addItem as addItemAction,
addChoice as addChoiceAction,
} from '../../assets/scripts/src/actions/index';
} from '../../assets/scripts/src/actions/actions';
describe('Choices', () => {
describe('should initialize Choices', () => {

View file

@ -8,12 +8,12 @@ module.exports = {
devtool: 'eval',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'./assets/scripts/src/choices'
'./src/scripts/src/choices'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'choices.min.js',
publicPath: '/assets/scripts/dist/',
publicPath: '/src/scripts/dist/',
library: 'Choices',
libraryTarget: 'umd',
},
@ -34,7 +34,7 @@ module.exports = {
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loaders: ['babel', 'eslint-loader'],
include: path.join(__dirname, 'assets/scripts/src')
include: path.join(__dirname, 'src/scripts/src')
}]
}
};

View file

@ -8,12 +8,12 @@ const minimize = process.argv.includes('--minimize');
const config = {
devtool: minimize ? false : 'cheap-module-source-map',
entry: [
'./assets/scripts/src/choices'
'./src/scripts/src/choices'
],
output: {
path: path.join(__dirname, '/assets/scripts/dist'),
path: path.join(__dirname, '/src/scripts/dist'),
filename: minimize ? 'choices.min.js' : 'choices.js',
publicPath: '/assets/scripts/dist/',
publicPath: '/src/scripts/dist/',
library: 'Choices',
libraryTarget: 'umd',
},
@ -34,7 +34,7 @@ const config = {
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loaders: ['babel'],
include: path.join(__dirname, 'assets/scripts/src')
include: path.join(__dirname, 'src/scripts/src')
}]
}
};