Skip to content

Commit

Permalink
better tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Dec 28, 2014
1 parent e77f9bf commit f555770
Show file tree
Hide file tree
Showing 10 changed files with 397 additions and 41 deletions.
Binary file added .DS_Store
Binary file not shown.
98 changes: 98 additions & 0 deletions .jshintrc
@@ -0,0 +1,98 @@
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details

"maxerr" : 50, // {int} Maximum error before stopping

// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
"indent" : 2, // {int} Number of spaces to use for indentation
"latedef" : false, // true: Require variables/functions to be defined before being used
"newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
"noempty" : true, // true: Prohibit use of empty blocks
"nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters.
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
"plusplus" : false, // true: Prohibit use of `++` & `--`
"quotmark" : "single", // Quotation mark consistency:
// false : do nothing (default)
// true : ensure whatever is used is consistent
// "single" : require single quotes
// "double" : require double quotes
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
"unused" : false, // true: Require all defined variables be used
"strict" : true, // true: Requires all functions run in ES5 Strict Mode
"maxparams" : false, // {int} Max number of formal params allowed per function
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
"maxstatements" : false, // {int} Max number statements per function
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
"maxlen" : false, // {int} Max number of characters per line

// Relaxing
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"boss" : false, // true: Tolerate assignments where comparisons would be expected
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // true: Tolerate use of `== null`
"es5" : true, // true: Allow ES5 syntax (ex: getters and setters)
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
// (ex: `for each`, multiple try/catch, function expression…)
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
"funcscope" : false, // true: Tolerate defining variables inside control statements
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
"iterator" : false, // true: Tolerate using the `__iterator__` property
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
"laxcomma" : false, // true: Tolerate comma-first style coding
"loopfunc" : false, // true: Tolerate functions being defined in loops
"multistr" : false, // true: Tolerate multi-line strings
"noyield" : false, // true: Tolerate generator functions with no yield statement in them.
"notypeof" : false, // true: Tolerate invalid typeof operator values
"proto" : false, // true: Tolerate using the `__proto__` property
"scripturl" : false, // true: Tolerate script-targeted URLs
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
"validthis" : false, // true: Tolerate using this in a non-constructor function

// Environments
"browser" : false, // Web Browser (window, document, etc)
"browserify" : true, // Browserify (node.js code in the browser)
"couch" : false, // CouchDB
"devel" : true, // Development/debugging (alert, confirm, etc)
"dojo" : false, // Dojo Toolkit
"jasmine" : false, // Jasmine
"jquery" : true, // jQuery
"mocha" : true, // Mocha
"mootools" : false, // MooTools
"node" : true, // Node.js
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
"prototypejs" : false, // Prototype and Scriptaculous
"qunit" : false, // QUnit
"rhino" : false, // Rhino
"shelljs" : false, // ShellJS
"worker" : false, // Web Workers
"wsh" : false, // Windows Scripting Host
"yui" : false, // Yahoo User Interface

// Custom Globals
// additional predefined global variables
"globals" : {
"describe": true,
"it": true,
"expect": true,
"assert": true,
"before" :true,
"after": true,
"mocha": true,
"sinon": true,
"chai": true
}
}
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -21,6 +21,21 @@ Please make sure to update correctly the themes.json file

New themes are welcome!

## Run the tests

Before running the tests install the npm dependencies

```shell
$ npm install
```

Your theme could be correctly imported only if it passes all the tests.
Run the tests using the following command:

```shell
$ npm run test
```

## Credits

Themes creators
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -23,8 +23,10 @@
"homepage": "http://colorsublime.com",
"devDependencies": {
"chai": "^1.10.0",
"color-parser": "^0.1.0",
"jsonlint": "^1.6.2",
"mocha": "^2.1.0",
"plist": "^1.1.0",
"walk": "^2.3.4"
}
}
3 changes: 1 addition & 2 deletions tests/jsonlint.spec.js
@@ -1,9 +1,8 @@
/* jshint node:true */
'use strict';
var jsonlint = require('jsonlint');

describe('Check the themes.json file', function() {
it('The themes.json is a valid json file', function() {
expect(jsonlint.parse(JSON.stringify(themes))).to.be.an('array');
expect(jsonlint.parse(themesJSON)).to.be.an('array');
});
});
19 changes: 15 additions & 4 deletions tests/runner.js
@@ -1,12 +1,23 @@
/* jshint node:true */
'use strict';

var chai = require('chai'),
fs = require('fs');
fs = require('fs'),
walk = require('walk'),
themesFiles = [],
walker = walk.walkSync('./themes', {
listeners: {
file: function(root, fileStats, next) {
themesFiles.push(fileStats);
}
}
});

// I know globals are never a good idea
// but in this case they work pretty well
global.themesFiles = themesFiles;
global.expect = chai.expect;
global.themes = JSON.parse(fs.readFileSync('./themes.json', 'utf8'));
global.themesJSON = fs.readFileSync('./themes.json', 'utf8');

require('./jsonlint.spec');
require('./themes-exsist.spec');
require('./themes-exist.spec');
require('./themes-parsing.spec');
7 changes: 7 additions & 0 deletions tests/themes-exist.spec.js
@@ -0,0 +1,7 @@
'use strict';

describe('All the themes exist', function() {
it('Any theme has an entry in the themes.json file and vice versa', function() {
expect(JSON.parse(themesJSON).length).to.be.equal(themesFiles.length);
});
});
22 changes: 0 additions & 22 deletions tests/themes-exsist.spec.js

This file was deleted.

0 comments on commit f555770

Please sign in to comment.