Skip to content

Commit 31b04f3

Browse files
committed
Fixed old reference to inputID, added blanket for unit testing
1 parent ecc0bb0 commit 31b04f3

File tree

7 files changed

+144
-121
lines changed

7 files changed

+144
-121
lines changed

Gruntfile.js

Lines changed: 93 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,121 @@
1-
'use strict';
1+
module.exports = function (grunt) {
22

3-
module.exports = function(grunt) {
4-
5-
// Project configuration.
6-
grunt.initConfig({
7-
// Metadata.
8-
pkg: grunt.file.readJSON('storelocator.jquery.json'),
9-
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
10-
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
11-
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
12-
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
13-
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
14-
// Task configuration.
15-
clean: {
16-
files: ['dist']
17-
},
18-
less: {
3+
// Project configuration.
4+
grunt.initConfig({
5+
// Metadata.
6+
pkg : grunt.file.readJSON('storelocator.jquery.json'),
7+
banner : '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
8+
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
9+
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
10+
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
11+
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
12+
// Task configuration.
13+
clean : {
14+
files: ['dist']
15+
},
16+
less : {
1917
dist: {
20-
src: 'src/css/storelocator.less',
18+
src : 'src/css/storelocator.less',
2119
dest: 'dist/css/storelocator.css'
20+
}
21+
},
22+
concat : {
23+
options: {
24+
stripBanners: true
2225
},
26+
dist : {
27+
src : ['src/js/jquery.<%= pkg.name %>.js'],
28+
dest: 'dist/js/jquery.<%= pkg.name %>.js'
29+
}
2330
},
24-
concat: {
25-
options: {
26-
stripBanners: true
27-
},
28-
dist: {
29-
src: ['src/js/jquery.<%= pkg.name %>.js'],
30-
dest: 'dist/js/jquery.<%= pkg.name %>.js'
31-
},
32-
},
33-
uglify: {
34-
dist: {
31+
uglify : {
32+
dist: {
3533
files: {
36-
'dist/js/jquery.<%= pkg.name %>.min.js' : '<%= concat.dist.dest %>',
37-
'dist/js/handlebars.min.js' : 'libs/handlebars/*.js',
38-
'dist/js/geocode.min.js' : 'src/js/geocode.js'
34+
'dist/js/jquery.<%= pkg.name %>.min.js': '<%= concat.dist.dest %>',
35+
'dist/js/handlebars.min.js' : 'libs/handlebars/*.js',
36+
'dist/js/geocode.min.js' : 'src/js/geocode.js'
3937
}
40-
},
41-
},
42-
qunit: {
43-
files: ['test/**/*.html']
44-
},
45-
jshint: {
46-
gruntfile: {
47-
options: {
48-
jshintrc: '.jshintrc'
49-
},
50-
src: 'Gruntfile.js'
51-
},
52-
src: {
53-
options: {
54-
jshintrc: 'src/.jshintrc'
55-
},
56-
src: ['src/**/*.js']
57-
},
58-
test: {
59-
options: {
60-
jshintrc: 'test/.jshintrc'
61-
},
62-
src: ['test/**/*.js']
63-
},
64-
},
38+
}
39+
},
40+
qunit : {
41+
files: ['test/**/*.html']
42+
},
43+
jshint : {
44+
gruntfile: {
45+
options: {
46+
jshintrc: '.jshintrc'
47+
},
48+
src : 'Gruntfile.js'
49+
},
50+
src : {
51+
options: {
52+
jshintrc: 'src/.jshintrc'
53+
},
54+
globals: {
55+
jQuery: true,
56+
google: true
57+
},
58+
src : ['src/**/*.js']
59+
},
60+
test : {
61+
options: {
62+
jshintrc: 'test/.jshintrc'
63+
},
64+
src : ['test/**/*.js']
65+
}
66+
},
6567
usebanner: {
6668
dist: {
6769
options: {
6870
position: 'top',
69-
banner: '<%= banner %>'
71+
banner : '<%= banner %>'
7072
},
71-
files: {
72-
'dist/js/jquery.<%= pkg.name %>.js' : 'dist/js/jquery.<%= pkg.name %>.js',
73-
'dist/js/jquery.<%= pkg.name %>.min.js' : 'dist/js/jquery.<%= pkg.name %>.min.js'
73+
files : {
74+
'dist/js/jquery.<%= pkg.name %>.js' : 'dist/js/jquery.<%= pkg.name %>.js',
75+
'dist/js/jquery.<%= pkg.name %>.min.js': 'dist/js/jquery.<%= pkg.name %>.min.js'
7476
}
75-
},
77+
}
7678
},
77-
cssmin: {
79+
cssmin : {
7880
dist: {
7981
files: {
80-
'dist/css/storelocator.min.css' : 'dist/css/storelocator.css'
82+
'dist/css/storelocator.min.css': 'dist/css/storelocator.css'
8183
}
82-
},
84+
}
8385
},
84-
watch: {
85-
gruntfile: {
86-
files: '<%= jshint.gruntfile.src %>',
87-
tasks: ['jshint:gruntfile']
88-
},
89-
src: {
90-
files: ['src/**/*'],
91-
tasks: ['less', 'concat', 'uglify', 'usebanner', 'cssmin'],
86+
watch : {
87+
gruntfile: {
88+
files: '<%= jshint.gruntfile.src %>',
89+
tasks: ['jshint:gruntfile']
90+
},
91+
src : {
92+
files : ['src/**/*'],
93+
tasks : ['less', 'concat', 'uglify', 'usebanner', 'cssmin'],
9294
options: {
93-
spawn: false,
95+
spawn : false,
9496
livereload: true
95-
},
96-
},
97-
test: {
98-
files: '<%= jshint.test.src %>',
99-
tasks: ['jshint:test', 'qunit']
100-
},
101-
},
102-
});
97+
}
98+
},
99+
test : {
100+
files: '<%= jshint.test.src %>',
101+
tasks: ['jshint:test', 'qunit']
102+
}
103+
}
104+
});
103105

104-
// These plugins provide necessary tasks.
105-
grunt.loadNpmTasks('grunt-contrib-clean');
106+
// These plugins provide necessary tasks.
107+
grunt.loadNpmTasks('grunt-contrib-clean');
106108
grunt.loadNpmTasks('grunt-contrib-less');
107-
grunt.loadNpmTasks('grunt-contrib-concat');
108-
grunt.loadNpmTasks('grunt-contrib-uglify');
109-
grunt.loadNpmTasks('grunt-contrib-qunit');
110-
grunt.loadNpmTasks('grunt-contrib-jshint');
111-
grunt.loadNpmTasks('grunt-contrib-watch');
109+
grunt.loadNpmTasks('grunt-contrib-concat');
110+
grunt.loadNpmTasks('grunt-contrib-uglify');
111+
grunt.loadNpmTasks('grunt-contrib-qunit');
112+
grunt.loadNpmTasks('grunt-contrib-jshint');
113+
grunt.loadNpmTasks('grunt-contrib-watch');
112114
grunt.loadNpmTasks('grunt-banner');
113115
grunt.loadNpmTasks('grunt-contrib-cssmin');
114116

115-
// Default task.
116-
grunt.registerTask('default', ['jshint', 'qunit', 'less', 'concat', 'uglify', 'usebanner', 'cssmin']);
117+
// Default task.
118+
grunt.registerTask('default', ['jshint', 'qunit', 'less', 'concat', 'uglify', 'usebanner', 'cssmin']);
117119
// Build
118120
grunt.registerTask('build', ['less', 'concat', 'uglify', 'usebanner', 'cssmin']);
119121
//Watch src build

dist/js/jquery.storelocator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295
_this.processForm(e);
296296
});
297297
$(document).on('keyup', function (e) {
298-
if (e.keyCode === 13 && $('#' + _this.settings.inputID).is(':focus')) {
298+
if (e.keyCode === 13 && $('#' + _this.settings.addressID).is(':focus')) {
299299
_this.processForm(e);
300300
}
301301
});

dist/js/jquery.storelocator.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/blanket/blanket.js

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/jquery.storelocator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297
_this.processForm(e);
298298
});
299299
$(document).on('keyup', function (e) {
300-
if (e.keyCode === 13 && $('#' + _this.settings.inputID).is(':focus')) {
300+
if (e.keyCode === 13 && $('#' + _this.settings.addressID).is(':focus')) {
301301
_this.processForm(e);
302302
}
303303
});

test/storeLocator.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,24 @@
33
<head>
44
<meta charset="utf-8">
55
<title>jQuery Google Maps Store Locator Plugin Test Suite</title>
6-
<!-- Load local jQuery. This can be overridden with a ?jquery=___ param. -->
7-
<script src="../libs/jquery-loader.js"></script>
6+
<!-- Load jQuery. This can be overridden with a ?jquery=___ param. -->
7+
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
88
<!-- Load local QUnit. -->
99
<link rel="stylesheet" href="../libs/qunit/qunit.css" media="screen">
1010
<script src="../libs/qunit/qunit.js"></script>
11+
<script src="../libs/blanket/blanket.js"></script>
1112
<!-- Load local lib and tests. -->
12-
<script src="../src/jquery.storeLocator.js"></script>
13+
<script src="../dist/js/handlebars.min.js"></script>
14+
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
15+
<script src="../dist/js/jquery.storelocator.js" data-cover></script>
1316
<script src="storeLocator_test.js"></script>
1417
<!-- Removing access to jQuery and $. But it'll still be available as _$, if
1518
you REALLY want to mess around with jQuery in the console. REMEMBER WE
1619
ARE TESTING A PLUGIN HERE, THIS HELPS ENSURE BEST PRACTICES. REALLY. -->
17-
<script>window._$ = jQuery.noConflict(true);</script>
20+
<!--<script>window._$ = jQuery.noConflict(true);</script>-->
1821
</head>
1922
<body>
2023
<div id="qunit"></div>
21-
<div id="qunit-fixture">
22-
<span>lame test markup</span>
23-
<span>normal test markup</span>
24-
<span>awesome test markup</span>
25-
</div>
24+
<div id="qunit-fixture"></div>
2625
</body>
2726
</html>

test/storeLocator_test.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,16 @@
3030
test('is chainable', function() {
3131
expect(1);
3232
// Not a bad test to run on collection methods.
33-
strictEqual(this.elems.storeLocator(), this.elems, 'should be chainable');
34-
});
35-
36-
test('is awesome', function() {
37-
expect(1);
38-
strictEqual(this.elems.storeLocator().text(), 'awesome0awesome1awesome2', 'should be awesome');
33+
strictEqual(this.elems.storeLocator(), this.elems, 'Should be chainable');
3934
});
4035

4136
module('jQuery.storeLocator');
4237

43-
test('is awesome', function() {
44-
expect(2);
45-
strictEqual($.storeLocator(), 'awesome.', 'should be awesome');
46-
strictEqual($.storeLocator({punctuation: '!'}), 'awesome!', 'should be thoroughly awesome');
47-
});
48-
4938
module(':storeLocator selector', {
5039
// This will run before each test in this module.
5140
setup: function() {
5241
this.elems = $('#qunit-fixture').children();
5342
}
5443
});
5544

56-
test('is awesome', function() {
57-
expect(1);
58-
// Use deepEqual & .get() when comparing jQuery objects.
59-
deepEqual(this.elems.filter(':storeLocator').get(), this.elems.last().get(), 'knows awesome when it sees it');
60-
});
61-
6245
}(jQuery));

0 commit comments

Comments
 (0)