Permalink
Browse files

Working my way through test skeleton

  • Loading branch information...
1 parent ca65afd commit 2baacbcafd4ea63b55052068aac02c7ba073e9e4 @twolfson twolfson committed Dec 6, 2012
Showing with 40 additions and 14 deletions.
  1. +1 −1 dist/jqueryp.js
  2. +1 −1 dist/jqueryp.min.js
  3. +3 −3 grunt.js
  4. +1 −1 src/templates/vanilla.mustache
  5. +1 −1 stage/jqueryp.js
  6. +1 −1 test/jqueryp.html
  7. +32 −6 test/jqueryp_test.js
View
@@ -69,4 +69,4 @@ $.exportModule = function (moduleName, module) {
return retVal;
};
};
-}(window.jQuery));
+}(jQuery));
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -75,8 +75,8 @@ module.exports = function(grunt) {
files: ['grunt.js', 'src/**/*.js', 'test/**/*.js']
},
watch: {
- files: '<config:lint.files>',
- tasks: 'lint test'
+ files: ['<config:lint.files>', '<config:qunit.files>'],
+ tasks: 'default'
},
jshint: {
options: {
@@ -108,6 +108,6 @@ module.exports = function(grunt) {
grunt.registerTask('test', 'qunit');
// Default task.
- grunt.registerTask('default', 'lint template test concat min');
+ grunt.registerTask('default', 'lint template concat min test');
};
@@ -1,3 +1,3 @@
(function ($, undefined) {
{{{jqueryp}}}
-}(window.jQuery));
+}(jQuery));
View
@@ -65,4 +65,4 @@ $.exportModule = function (moduleName, module) {
return retVal;
};
};
-}(window.jQuery));
+}(jQuery));
View
@@ -9,7 +9,7 @@
<link rel="stylesheet" href="../libs/qunit/qunit.css" media="screen">
<script src="../libs/qunit/qunit.js"></script>
<!-- Load local lib and tests. -->
- <script src="../src/jqueryp.js"></script>
+ <script src="../dist/jqueryp.js"></script>
<script src="jqueryp_test.js"></script>
<!-- Removing access to jQuery and $. But it'll still be available as _$, if
you REALLY want to mess around with jQuery in the console. REMEMBER WE
View
@@ -36,19 +36,45 @@
raises(block, [expected], [message])
*/
- module('jQuery#awesome', {
+ module('jQuery#exportModule', {
setup: function() {
this.elems = $('#qunit-fixture').children();
}
});
- test('is chainable', 1, function() {
- // Not a bad test to run on collection methods.
- strictEqual(this.elems.awesome(), this.elems, 'should be chaninable');
+ test('exists', 1, function() {
+ ok($.exportModule, '$.exportModule does not exist');
});
- test('is awesome', 1, function() {
- strictEqual(this.elems.awesome().text(), 'awesomeawesomeawesome', 'should be thoroughly awesome');
+ module('A toggle class added via jQuery#exportModule', {
+ setup: function() {
+ this.elems = $('#qunit-fixture').children();
+
+ // Create the toggle class
+ function Toggle(elt) {
+ var $elt = $(elt),
+ that = this;
+
+ this.$elt = $elt;
+
+ // Save the toggle class to the element
+ $elt.addClass('toggle');
+ }
+ Toggle.prototype = {
+ 'toggle': function () {
+ // Toggle the class
+ var $item = this.$item;
+ $item.toggleClass('is-selected');
+ }
+ };
+
+ // Expose it via jqueryp
+ $.exportModule('toggle', Toggle);
+ }
+ });
+
+ test('exists on jQuery collections', 1, function() {
+ ok(this.elems.toggle, 'toggle should exist on jQuery collections');
});
module('jQuery.awesome');

0 comments on commit 2baacbc

Please sign in to comment.