Skip to content

Commit

Permalink
Test cases improved.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmariuzzo committed Jul 9, 2016
1 parent 45282ea commit e5f8cc1
Show file tree
Hide file tree
Showing 16 changed files with 424 additions and 340 deletions.
117 changes: 61 additions & 56 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,77 @@

module.exports = function (grunt) {

// Load all Grunt tasks.
require('load-grunt-tasks')(grunt);
// Load all Grunt tasks.
require('load-grunt-tasks')(grunt);

// Grunt configuration.
grunt.initConfig({
// Grunt configuration.
grunt.initConfig({

pkg: grunt.file.readJSON('package.json'),
pkg: grunt.file.readJSON('package.json'),

clean: ['dist'],
clean: ['dist'],

watch: {
scripts: {
files: [
'Gruntfile.js',
'src/**/*.js',
'tests/specs/**/*.js',
'!.grunt'
],
tasks: ['jshint', 'jasmine']
}
},
watch: {
scripts: {
files: [
'Gruntfile.js',
'src/**/*.js',
'tests/specs/**/*.js',
'tests/helpers.js',
'!.grunt'
],
tasks: ['jshint', 'jasmine']
}
},

uglify: {
all: {
files: {
'dist/jquery.checkboxes-<%= pkg.version %>.min.js': ['src/jquery.checkboxes.js']
uglify: {
all: {
files: {
'dist/jquery.checkboxes-<%= pkg.version %>.min.js': ['src/jquery.checkboxes.js']
},
options: {
banner: '/*! checkboxes.js v<%= pkg.version %> | ' +
'(c) 2013, <%= grunt.template.today("yyyy") %> Rubens Mariuzzo | ' +
'http://github.com/rmariuzzo/checkboxes.js/LICENSE */',
}
}
},
options: {
banner: '/*! checkboxes.js v<%= pkg.version %> | ' +
'(c) 2013, <%= grunt.template.today("yyyy") %> Rubens Mariuzzo | ' +
'http://github.com/rmariuzzo/checkboxes.js/LICENSE */',
}
}
},

jshint: {
all: {
src: [
'Gruntfile.js',
'src/**/*.js',
'tests/spec/**/*.js'
],
options: {
jshintrc: true
}
}
},
jshint: {
all: {
src: [
'Gruntfile.js',
'src/**/*.js',
'tests/spec/**/*.js'
],
options: {
jshintrc: '<%= baseDir %>.jshintrc',
reporterOutput: ''
}
}
},

jasmine: {
all: {
src: 'src/**/*.js',
options: {
specs: 'tests/specs/*_spec.js',
vendor: [
'bower_components/jquery/dist/jquery.min.js',
'bower_components/jasmine-jquery/lib/jasmine-jquery.js'
]
jasmine: {
all: {
src: 'src/**/*.js',
options: {
specs: 'tests/specs/*_spec.js',
vendor: [
'bower_components/jquery/dist/jquery.min.js',
'bower_components/jasmine-jquery/lib/jasmine-jquery.js'
],
helpers: [
'tests/helpers.js'
]
}
}
}
}
}

});
});

grunt.registerTask('default', ['jshint', 'watch']);
grunt.registerTask('build', ['clean', 'jshint', 'jasmine', 'uglify']);
grunt.registerTask('test', ['jasmine']);
grunt.registerTask('travis', ['jshint', 'jasmine']);
grunt.registerTask('default', ['jshint', 'watch']);
grunt.registerTask('build', ['clean', 'jshint', 'jasmine', 'uglify']);
grunt.registerTask('test', ['jasmine']);
grunt.registerTask('travis', ['jshint', 'jasmine']);

};
60 changes: 30 additions & 30 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"name": "checkboxes.js",
"version": "1.0.5",
"homepage": "http://rmariuzzo.github.io/checkboxes.js/",
"authors": [
"Rubens Mariuzzo <[email protected]>"
],
"description": "A jQuery plugin that give you nice powers over your checkboxes.",
"main": "src/jquery.checkboxes.js",
"keywords": [
"checkbox",
"checkboxes",
"jquery",
"plugin",
"check",
"uncheck",
"range",
"selection"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"devDependencies": {
"jquery": "~2.1.1",
"jasmine-jquery": "~2.0.3"
}
"name": "checkboxes.js",
"version": "1.0.5",
"homepage": "http://rmariuzzo.github.io/checkboxes.js/",
"authors": [
"Rubens Mariuzzo <[email protected]>"
],
"description": "A jQuery plugin that give you nice powers over your checkboxes.",
"main": "src/jquery.checkboxes.js",
"keywords": [
"checkbox",
"checkboxes",
"jquery",
"plugin",
"check",
"uncheck",
"range",
"selection"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"devDependencies": {
"jquery": "~2.1.1",
"jasmine-jquery": "~2.0.3"
}
}
72 changes: 36 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"name": "checkboxes.js",
"version": "1.0.6",
"description": "A jQuery plugin that gives you nice powers over your checkboxes.",
"keywords": [
"checkbox",
"checkboxes",
"range",
"jquery",
"plugin"
],
"homepage": "https://github.com/rmariuzzo/checkboxes.js",
"bugs": "https://github.com/rmariuzzo/checkboxes.js/issues",
"license": "MIT",
"author": {
"name": "Rubens Mariuzzo",
"email": "[email protected]",
"url": "https://github.com/rmariuzzo"
},
"contributors": [],
"main": "dist/jquery.checkboxes-1.0.6.min.js",
"repository": {
"type": "git",
"url": "https://github.com/rmariuzzo/checkboxes.js.git"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-jasmine": "~0.6.5",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "~0.6.1",
"load-grunt-tasks": "~0.4.0"
},
"scripts": {
"test": "grunt travis --verbose"
}
"name": "checkboxes.js",
"version": "1.0.6",
"description": "A jQuery plugin that gives you nice powers over your checkboxes.",
"keywords": [
"checkbox",
"checkboxes",
"range",
"jquery",
"plugin"
],
"homepage": "https://github.com/rmariuzzo/checkboxes.js",
"bugs": "https://github.com/rmariuzzo/checkboxes.js/issues",
"license": "MIT",
"author": {
"name": "Rubens Mariuzzo",
"email": "[email protected]",
"url": "https://github.com/rmariuzzo"
},
"contributors": [],
"main": "dist/jquery.checkboxes-1.0.6.min.js",
"repository": {
"type": "git",
"url": "https://github.com/rmariuzzo/checkboxes.js.git"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-jasmine": "~0.6.5",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "~0.6.1",
"load-grunt-tasks": "~0.4.0"
},
"scripts": {
"test": "grunt travis --verbose"
}
}
9 changes: 5 additions & 4 deletions src/jquery.checkboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
Checkboxes.prototype.check = function () {
this.$context.find(':checkbox')
.filter(':not(:disabled)')
.filter(':visible')
.prop('checked', true);
};

/**
* Uncheck all checkboxes in context.
*/
Checkboxes.prototype.uncheck = function () {
this.$context.find(':checkbox')
this.$context.find(':checkbox:visible')
.filter(':not(:disabled)')
.prop('checked', false);
};
Expand All @@ -37,7 +38,7 @@
* Toggle the state of all checkboxes in context.
*/
Checkboxes.prototype.toggle = function () {
this.$context.find(':checkbox')
this.$context.find(':checkbox:visible')
.filter(':not(:disabled)')
.each(function () {
var $checkbox = $(this);
Expand All @@ -63,7 +64,7 @@
});
} else {
// Disable max.
this.$context.off('click.checkboxes');
this.$context.off('click.checkboxes.max');
}
};

Expand All @@ -80,7 +81,7 @@
var $checkbox = $(event.target);

if (event.shiftKey && instance.$last) {
var $checkboxes = instance.$context.find(':checkbox');
var $checkboxes = instance.$context.find(':checkbox:visible');
var from = $checkboxes.index(instance.$last);
var to = $checkboxes.index($checkbox);
var start = Math.min(from, to);
Expand Down
3 changes: 2 additions & 1 deletion tests/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"spyOn": true,
"jasmine": true,
"$": true,
"loadFixtures": true
"loadFixtures": true,
"setupContext": true,
}
}
65 changes: 35 additions & 30 deletions tests/fixtures/checked.html
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title></title>
</head>

<body>
<input type="checkbox" id="1" checked>
<label for="1">Row #1</label>
<br>
<input type="checkbox" id="2" checked>
<label for="2">Row #2</label>
<br>
<input type="checkbox" id="3" checked>
<label for="3">Row #3</label>
<br>
<input type="checkbox" id="4" checked>
<label for="4">Row #4</label>
<br>
<input type="checkbox" id="5" checked>
<label for="5">Row #5</label>
<br>
<input type="checkbox" id="6" checked>
<label for="6">Row #6</label>
<br>
<input type="checkbox" id="7" checked disabled="disabled">
<label for="7">Row #7</label>
<br>
<input type="checkbox" id="8" checked>
<label for="8">Row #8</label>
<br>
<input type="checkbox" id="9" checked>
<label for="9">Row #9</label>
<br>
<input type="checkbox" id="10" checked>
<label for="10">Row #10</label>
<div id="context">
<input type="checkbox" id="1" checked>
<label for="1">Row #1</label>
<br>
<input type="checkbox" id="2" checked>
<label for="2">Row #2</label>
<br>
<input type="checkbox" id="3" checked>
<label for="3">Row #3</label>
<br>
<input type="checkbox" id="4" checked>
<label for="4">Row #4</label>
<br>
<input type="checkbox" id="5" checked style="display:none">
<label for="5">Row #5</label>
<br>
<input type="checkbox" id="6" checked>
<label for="6">Row #6</label>
<br>
<input type="checkbox" id="7" checked disabled="disabled">
<label for="7">Row #7</label>
<br>
<input type="checkbox" id="8" checked>
<label for="8">Row #8</label>
<br>
<input type="checkbox" id="9" checked>
<label for="9">Row #9</label>
<br>
<input type="checkbox" id="10" checked>
<label for="10">Row #10</label>
</div>
</body>
</html>

</html>
Loading

0 comments on commit e5f8cc1

Please sign in to comment.