Skip to content

Commit e5f8cc1

Browse files
committed
Test cases improved.
1 parent 45282ea commit e5f8cc1

16 files changed

+424
-340
lines changed

Gruntfile.js

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,77 @@
22

33
module.exports = function (grunt) {
44

5-
// Load all Grunt tasks.
6-
require('load-grunt-tasks')(grunt);
5+
// Load all Grunt tasks.
6+
require('load-grunt-tasks')(grunt);
77

8-
// Grunt configuration.
9-
grunt.initConfig({
8+
// Grunt configuration.
9+
grunt.initConfig({
1010

11-
pkg: grunt.file.readJSON('package.json'),
11+
pkg: grunt.file.readJSON('package.json'),
1212

13-
clean: ['dist'],
13+
clean: ['dist'],
1414

15-
watch: {
16-
scripts: {
17-
files: [
18-
'Gruntfile.js',
19-
'src/**/*.js',
20-
'tests/specs/**/*.js',
21-
'!.grunt'
22-
],
23-
tasks: ['jshint', 'jasmine']
24-
}
25-
},
15+
watch: {
16+
scripts: {
17+
files: [
18+
'Gruntfile.js',
19+
'src/**/*.js',
20+
'tests/specs/**/*.js',
21+
'tests/helpers.js',
22+
'!.grunt'
23+
],
24+
tasks: ['jshint', 'jasmine']
25+
}
26+
},
2627

27-
uglify: {
28-
all: {
29-
files: {
30-
'dist/jquery.checkboxes-<%= pkg.version %>.min.js': ['src/jquery.checkboxes.js']
28+
uglify: {
29+
all: {
30+
files: {
31+
'dist/jquery.checkboxes-<%= pkg.version %>.min.js': ['src/jquery.checkboxes.js']
32+
},
33+
options: {
34+
banner: '/*! checkboxes.js v<%= pkg.version %> | ' +
35+
'(c) 2013, <%= grunt.template.today("yyyy") %> Rubens Mariuzzo | ' +
36+
'http://github.com/rmariuzzo/checkboxes.js/LICENSE */',
37+
}
38+
}
3139
},
32-
options: {
33-
banner: '/*! checkboxes.js v<%= pkg.version %> | ' +
34-
'(c) 2013, <%= grunt.template.today("yyyy") %> Rubens Mariuzzo | ' +
35-
'http://github.com/rmariuzzo/checkboxes.js/LICENSE */',
36-
}
37-
}
38-
},
3940

40-
jshint: {
41-
all: {
42-
src: [
43-
'Gruntfile.js',
44-
'src/**/*.js',
45-
'tests/spec/**/*.js'
46-
],
47-
options: {
48-
jshintrc: true
49-
}
50-
}
51-
},
41+
jshint: {
42+
all: {
43+
src: [
44+
'Gruntfile.js',
45+
'src/**/*.js',
46+
'tests/spec/**/*.js'
47+
],
48+
options: {
49+
jshintrc: '<%= baseDir %>.jshintrc',
50+
reporterOutput: ''
51+
}
52+
}
53+
},
5254

53-
jasmine: {
54-
all: {
55-
src: 'src/**/*.js',
56-
options: {
57-
specs: 'tests/specs/*_spec.js',
58-
vendor: [
59-
'bower_components/jquery/dist/jquery.min.js',
60-
'bower_components/jasmine-jquery/lib/jasmine-jquery.js'
61-
]
55+
jasmine: {
56+
all: {
57+
src: 'src/**/*.js',
58+
options: {
59+
specs: 'tests/specs/*_spec.js',
60+
vendor: [
61+
'bower_components/jquery/dist/jquery.min.js',
62+
'bower_components/jasmine-jquery/lib/jasmine-jquery.js'
63+
],
64+
helpers: [
65+
'tests/helpers.js'
66+
]
67+
}
68+
}
6269
}
63-
}
64-
}
6570

66-
});
71+
});
6772

68-
grunt.registerTask('default', ['jshint', 'watch']);
69-
grunt.registerTask('build', ['clean', 'jshint', 'jasmine', 'uglify']);
70-
grunt.registerTask('test', ['jasmine']);
71-
grunt.registerTask('travis', ['jshint', 'jasmine']);
73+
grunt.registerTask('default', ['jshint', 'watch']);
74+
grunt.registerTask('build', ['clean', 'jshint', 'jasmine', 'uglify']);
75+
grunt.registerTask('test', ['jasmine']);
76+
grunt.registerTask('travis', ['jshint', 'jasmine']);
7277

7378
};

bower.json

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2-
"name": "checkboxes.js",
3-
"version": "1.0.5",
4-
"homepage": "http://rmariuzzo.github.io/checkboxes.js/",
5-
"authors": [
6-
"Rubens Mariuzzo <rubens@mariuzzo.com>"
7-
],
8-
"description": "A jQuery plugin that give you nice powers over your checkboxes.",
9-
"main": "src/jquery.checkboxes.js",
10-
"keywords": [
11-
"checkbox",
12-
"checkboxes",
13-
"jquery",
14-
"plugin",
15-
"check",
16-
"uncheck",
17-
"range",
18-
"selection"
19-
],
20-
"license": "MIT",
21-
"ignore": [
22-
"**/.*",
23-
"node_modules",
24-
"bower_components",
25-
"test",
26-
"tests"
27-
],
28-
"devDependencies": {
29-
"jquery": "~2.1.1",
30-
"jasmine-jquery": "~2.0.3"
31-
}
2+
"name": "checkboxes.js",
3+
"version": "1.0.5",
4+
"homepage": "http://rmariuzzo.github.io/checkboxes.js/",
5+
"authors": [
6+
"Rubens Mariuzzo <rubens@mariuzzo.com>"
7+
],
8+
"description": "A jQuery plugin that give you nice powers over your checkboxes.",
9+
"main": "src/jquery.checkboxes.js",
10+
"keywords": [
11+
"checkbox",
12+
"checkboxes",
13+
"jquery",
14+
"plugin",
15+
"check",
16+
"uncheck",
17+
"range",
18+
"selection"
19+
],
20+
"license": "MIT",
21+
"ignore": [
22+
"**/.*",
23+
"node_modules",
24+
"bower_components",
25+
"test",
26+
"tests"
27+
],
28+
"devDependencies": {
29+
"jquery": "~2.1.1",
30+
"jasmine-jquery": "~2.0.3"
31+
}
3232
}

package.json

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
{
2-
"name": "checkboxes.js",
3-
"version": "1.0.6",
4-
"description": "A jQuery plugin that gives you nice powers over your checkboxes.",
5-
"keywords": [
6-
"checkbox",
7-
"checkboxes",
8-
"range",
9-
"jquery",
10-
"plugin"
11-
],
12-
"homepage": "https://github.com/rmariuzzo/checkboxes.js",
13-
"bugs": "https://github.com/rmariuzzo/checkboxes.js/issues",
14-
"license": "MIT",
15-
"author": {
16-
"name": "Rubens Mariuzzo",
17-
"email": "rubens@mariuzzo.com",
18-
"url": "https://github.com/rmariuzzo"
19-
},
20-
"contributors": [],
21-
"main": "dist/jquery.checkboxes-1.0.6.min.js",
22-
"repository": {
23-
"type": "git",
24-
"url": "https://github.com/rmariuzzo/checkboxes.js.git"
25-
},
26-
"devDependencies": {
27-
"grunt": "~0.4.1",
28-
"grunt-contrib-clean": "^0.6.0",
29-
"grunt-contrib-jasmine": "~0.6.5",
30-
"grunt-contrib-jshint": "~0.10.0",
31-
"grunt-contrib-uglify": "~0.2.2",
32-
"grunt-contrib-watch": "~0.6.1",
33-
"load-grunt-tasks": "~0.4.0"
34-
},
35-
"scripts": {
36-
"test": "grunt travis --verbose"
37-
}
2+
"name": "checkboxes.js",
3+
"version": "1.0.6",
4+
"description": "A jQuery plugin that gives you nice powers over your checkboxes.",
5+
"keywords": [
6+
"checkbox",
7+
"checkboxes",
8+
"range",
9+
"jquery",
10+
"plugin"
11+
],
12+
"homepage": "https://github.com/rmariuzzo/checkboxes.js",
13+
"bugs": "https://github.com/rmariuzzo/checkboxes.js/issues",
14+
"license": "MIT",
15+
"author": {
16+
"name": "Rubens Mariuzzo",
17+
"email": "rubens@mariuzzo.com",
18+
"url": "https://github.com/rmariuzzo"
19+
},
20+
"contributors": [],
21+
"main": "dist/jquery.checkboxes-1.0.6.min.js",
22+
"repository": {
23+
"type": "git",
24+
"url": "https://github.com/rmariuzzo/checkboxes.js.git"
25+
},
26+
"devDependencies": {
27+
"grunt": "~0.4.1",
28+
"grunt-contrib-clean": "^0.6.0",
29+
"grunt-contrib-jasmine": "~0.6.5",
30+
"grunt-contrib-jshint": "~0.10.0",
31+
"grunt-contrib-uglify": "~0.2.2",
32+
"grunt-contrib-watch": "~0.6.1",
33+
"load-grunt-tasks": "~0.4.0"
34+
},
35+
"scripts": {
36+
"test": "grunt travis --verbose"
37+
}
3838
}

src/jquery.checkboxes.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121
Checkboxes.prototype.check = function () {
2222
this.$context.find(':checkbox')
2323
.filter(':not(:disabled)')
24+
.filter(':visible')
2425
.prop('checked', true);
2526
};
2627

2728
/**
2829
* Uncheck all checkboxes in context.
2930
*/
3031
Checkboxes.prototype.uncheck = function () {
31-
this.$context.find(':checkbox')
32+
this.$context.find(':checkbox:visible')
3233
.filter(':not(:disabled)')
3334
.prop('checked', false);
3435
};
@@ -37,7 +38,7 @@
3738
* Toggle the state of all checkboxes in context.
3839
*/
3940
Checkboxes.prototype.toggle = function () {
40-
this.$context.find(':checkbox')
41+
this.$context.find(':checkbox:visible')
4142
.filter(':not(:disabled)')
4243
.each(function () {
4344
var $checkbox = $(this);
@@ -63,7 +64,7 @@
6364
});
6465
} else {
6566
// Disable max.
66-
this.$context.off('click.checkboxes');
67+
this.$context.off('click.checkboxes.max');
6768
}
6869
};
6970

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

8283
if (event.shiftKey && instance.$last) {
83-
var $checkboxes = instance.$context.find(':checkbox');
84+
var $checkboxes = instance.$context.find(':checkbox:visible');
8485
var from = $checkboxes.index(instance.$last);
8586
var to = $checkboxes.index($checkbox);
8687
var start = Math.min(from, to);

tests/.jshintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"spyOn": true,
2323
"jasmine": true,
2424
"$": true,
25-
"loadFixtures": true
25+
"loadFixtures": true,
26+
"setupContext": true,
2627
}
2728
}

tests/fixtures/checked.html

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,43 @@
11
<!doctype html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<title></title>
67
</head>
8+
79
<body>
8-
<input type="checkbox" id="1" checked>
9-
<label for="1">Row #1</label>
10-
<br>
11-
<input type="checkbox" id="2" checked>
12-
<label for="2">Row #2</label>
13-
<br>
14-
<input type="checkbox" id="3" checked>
15-
<label for="3">Row #3</label>
16-
<br>
17-
<input type="checkbox" id="4" checked>
18-
<label for="4">Row #4</label>
19-
<br>
20-
<input type="checkbox" id="5" checked>
21-
<label for="5">Row #5</label>
22-
<br>
23-
<input type="checkbox" id="6" checked>
24-
<label for="6">Row #6</label>
25-
<br>
26-
<input type="checkbox" id="7" checked disabled="disabled">
27-
<label for="7">Row #7</label>
28-
<br>
29-
<input type="checkbox" id="8" checked>
30-
<label for="8">Row #8</label>
31-
<br>
32-
<input type="checkbox" id="9" checked>
33-
<label for="9">Row #9</label>
34-
<br>
35-
<input type="checkbox" id="10" checked>
36-
<label for="10">Row #10</label>
10+
<div id="context">
11+
<input type="checkbox" id="1" checked>
12+
<label for="1">Row #1</label>
13+
<br>
14+
<input type="checkbox" id="2" checked>
15+
<label for="2">Row #2</label>
16+
<br>
17+
<input type="checkbox" id="3" checked>
18+
<label for="3">Row #3</label>
19+
<br>
20+
<input type="checkbox" id="4" checked>
21+
<label for="4">Row #4</label>
22+
<br>
23+
<input type="checkbox" id="5" checked style="display:none">
24+
<label for="5">Row #5</label>
25+
<br>
26+
<input type="checkbox" id="6" checked>
27+
<label for="6">Row #6</label>
28+
<br>
29+
<input type="checkbox" id="7" checked disabled="disabled">
30+
<label for="7">Row #7</label>
31+
<br>
32+
<input type="checkbox" id="8" checked>
33+
<label for="8">Row #8</label>
34+
<br>
35+
<input type="checkbox" id="9" checked>
36+
<label for="9">Row #9</label>
37+
<br>
38+
<input type="checkbox" id="10" checked>
39+
<label for="10">Row #10</label>
40+
</div>
3741
</body>
38-
</html>
42+
43+
</html>

0 commit comments

Comments
 (0)