Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Jul 4, 2018
1 parent 4f35f1e commit 586645a
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 975 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ styles/selectivity-custom.sass

.sass-cache
node_modules
yarn-error.log

# OS X mess
.DS_Store
Expand Down
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
language: node_js
node_js:
- "6"
before_script:
- npm install -g yarn
- "8"
24 changes: 3 additions & 21 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,11 @@
"stopOnEntry": false,
"args": ["unit-tests"],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"protocol": "inspector",
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
"console": "internalConsole"
}
]
}
}
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"files.trimTrailingWhitespace": true,
"prettier.eslintIntegration": true,
"prettier.bracketSpacing": true,
"prettier.disableLanguages": ["json"],
"prettier.jsxBracketSameLine": true,
"prettier.parser": "babylon",
"prettier.printWidth": 100,
Expand Down
167 changes: 86 additions & 81 deletions README.md

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions gulp/argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ var argv = yargs
describe: 'Adds a source map to the build for debugging.',
type: 'boolean'
})
.option('test', {
default: '',
describe:
'Specify the name of a specific test to execute in combination with ' +
'`gulp unit-tests`.',
type: 'string'
})
.strict()
.wrap(yargs.terminalWidth()).argv;

Expand Down
12 changes: 0 additions & 12 deletions gulp/tasks/unit-tests.js

This file was deleted.

9 changes: 1 addition & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
'use strict';

var gulp = require('./gulp')([
'browserify',
'browser-sync',
'sass',
'unit-tests',
'usage',
'watch'
]);
var gulp = require('./gulp')(['browserify', 'browser-sync', 'sass', 'usage', 'watch']);

gulp.task('default', ['browserify', 'sass']);

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
"url": "git://github.com/arendjr/selectivity.git"
},
"scripts": {
"build": "yarn build-jquery-source && yarn build-jquery-min && yarn build-react-min && yarn build-react-source && yarn build-vanilla-min && yarn build-vanilla-source",
"build-jquery-min": "gulp --api=jquery --bundle-name=jquery --exclude-modules=plugins/options-validator --minify",
"build-jquery-source": "gulp --api=jquery --bundle-name=jquery --derequire",
"build-react-min": "gulp --api=react --bundle-name=react --exclude-modules=plugins/options-validator --export-global --minify",
"build-react-source": "gulp --api=react --bundle-name=react --export-global --derequire",
"build-vanilla-min": "gulp --bundle-name= --exclude-modules=plugins/options-validator --export-global --minify",
"build-vanilla-source": "gulp --bundle-name= --export-global --derequire",
"build": "npm run build-jquery-source && npm run build-jquery-min && npm run build-react-min && npm run build-react-source && npm run build-vanilla-min && npm run build-vanilla-source",
"lint": "eslint .",
"test": "eslint . && gulp unit-tests"
"start": "gulp dev --export-global --source-map",
"test": "yarn lint && yarn unit-tests",
"unit-tests": "node tools/unit-tests.js"
},
"devDependencies": {
"browser-sync": "^2.14.0",
Expand All @@ -34,10 +36,8 @@
"gulp-derequire": "^2.0.0",
"gulp-header": "^1.7.1",
"gulp-if": "^2.0.0",
"gulp-nodeunit": "^0.1.0",
"gulp-replace": "^1.0.0",
"gulp-ruby-sass": "^3.0.0",
"gulp-tape": "0.0.11",
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.1",
"jquery": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/selectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ assign(Selectivity.prototype, {
* @see getValue()
*/
triggerChange: function(options) {
var data = assign({ date: this._data, value: this._value }, options);
var data = assign({ data: this._data, value: this._value }, options);
this.triggerEvent('change', data);
this.triggerEvent('selectivity-change', data);
},
Expand Down
4 changes: 2 additions & 2 deletions tests/test-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
* async - Set to true to indicate the test function is asynchronous and calls
* done() itself.
* @param fn The actual test function. Receives three arguments:
* test - The nodeunit test instance.
* test - The tape test instance.
* $input - jQuery container for the '#selectivity-input' element defined in
* resources/testcase.html.
* $ - jQuery instance.
Expand Down Expand Up @@ -76,7 +76,7 @@ module.exports = {
* async - Set to true to indicate the test function is asynchronous and calls
* done() itself.
* @param fn The actual test function. Receives three arguments:
* test - The nodeunit test instance.
* test - The tape test instance.
* $input - jQuery container for the '#selectivity-input' element defined in
* resources/testcase.html.
* $ - jQuery instance.
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/jquery/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ TestUtil.createJQueryTest(
);

TestUtil.createJQueryTest(
'jquery/multiple: test load more with multiple input',
'jquery/dropdown: test load more with multiple input',
['inputs/multiple', 'dropdown', 'templates'],
function(test, $input, $) {
var offset = null;
Expand Down
24 changes: 8 additions & 16 deletions tests/unit/jquery/submenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@ TestUtil.createJQueryTest(
text: 'First Item',
submenu: {
items: [
{
id: 2,
text: 'First subitem'
},
{
id: 3,
text: 'Second subitem'
}
{ id: 2, text: 'First subitem' },
{ id: 3, text: 'Second subitem' }
],
showSearchInput: true
}
Expand All @@ -52,6 +46,10 @@ TestUtil.createJQueryTest(

TestUtil.simulateEvent($input[0], 'click');

test.equal($('.selectivity-dropdown').length, 1);

TestUtil.simulateEvent('.selectivity-result-item[data-item-id="1"]', 'mouseenter');

test.equal($('.selectivity-dropdown').length, 2);

TestUtil.simulateEvent('.selectivity-result-item[data-item-id="2"]', 'click');
Expand All @@ -72,14 +70,8 @@ TestUtil.createJQueryTest(
text: 'First Item',
submenu: {
items: [
{
id: 2,
text: 'First subitem'
},
{
id: 3,
text: 'Second subitem'
}
{ id: 2, text: 'First subitem' },
{ id: 3, text: 'Second subitem' }
],
showSearchInput: true
}
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/react/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ TestUtil.createReactTest(
['inputs/single', 'dropdown', 'templates'],
{ async: true, data: data, items: items, onChange: noop },
function(SelectivityReact, test, ref, container) {
test.plan(3);
test.plan(4);

changeEvent = null;

Expand All @@ -81,6 +81,7 @@ TestUtil.createReactTest(

test.equal(ref.getValue(), 2);
test.equal(changeEvent.value, 2);
test.deepEqual(changeEvent.data, { id: 2, text: 'Antwerp' });

test.end();
}
Expand Down
26 changes: 6 additions & 20 deletions tests/unit/react/submenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,7 @@ TestUtil.createReactTest(
id: 1,
text: 'First Item',
submenu: {
items: [
{
id: 2,
text: 'First subitem'
},
{
id: 3,
text: 'Second subitem'
}
],
items: [{ id: 2, text: 'First subitem' }, { id: 3, text: 'Second subitem' }],
showSearchInput: true
}
}
Expand All @@ -55,6 +46,10 @@ TestUtil.createReactTest(

TestUtil.simulateEvent(container.firstChild, 'click');

test.equal($('.selectivity-dropdown').length, 1);

TestUtil.simulateEvent('.selectivity-result-item[data-item-id="1"]', 'mouseenter');

test.equal($('.selectivity-dropdown').length, 2);

TestUtil.simulateEvent('.selectivity-result-item[data-item-id="2"]', 'click');
Expand All @@ -73,16 +68,7 @@ TestUtil.createReactTest(
id: 1,
text: 'First Item',
submenu: {
items: [
{
id: 2,
text: 'First subitem'
},
{
id: 3,
text: 'Second subitem'
}
],
items: [{ id: 2, text: 'First subitem' }, { id: 3, text: 'Second subitem' }],
showSearchInput: true
}
}
Expand Down
32 changes: 32 additions & 0 deletions tools/unit-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

var argv = require('yargs').argv;
var execSync = require('child_process').execSync;
var glob = require('glob');

var tests = glob.sync('tests/unit/' + (argv.test || '**/*') + '.js');
if (tests.length === 0) {
console.log('Unknown test: ' + argv.test);
console.log(
'Available tests:\n ' +
glob
.sync('tests/unit/**/*.js')
.map(function(path) {
return path.slice(11, -3);
})
.join('\n ')
);
process.exit(1);
}

tests.forEach(function(test) {
try {
execSync('node ' + test + ' | node_modules/.bin/faucet', {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit'
});
} catch (exception) {
process.exit(exception.status);
}
});
Loading

0 comments on commit 586645a

Please sign in to comment.