Permalink
Browse files

fixed formatting

  • Loading branch information...
1 parent 32d48a5 commit 97b5929c549fc1ee8adc00d37ef4c683ea02fe81 @hakanson committed Oct 3, 2011
Showing with 86 additions and 85 deletions.
  1. +37 −36 tests/amplify.tests.js
  2. +49 −49 tests/jquery.tests.js
View
@@ -1,46 +1,47 @@
-var triggerData = { "key" : "value" };
-
-module("AmplifyJS Pub/Sub");
-
-test("amplify.publish", function() {
-var a = null;
+/*global amplify,QUnit,test,module,equal,deepEqual*/
+var triggerData = { "key" : "value" };
+
+module( "AmplifyJS Pub/Sub" );
+
+test( "amplify.publish", function() {
+ var a = null;
-amplify.subscribe('custom', function(data) {
- a = data;
-});
-amplify.publish('custom', triggerData);
+ amplify.subscribe( "custom", function( data ) {
+ a = data;
+ } );
+ amplify.publish( "custom", triggerData );
-deepEqual(a, triggerData);
-});
+ deepEqual( a, triggerData );
+} );
-test("amplify.publish with two subscribers", function() {
-var count = 0;
+test( "amplify.publish with two subscribers", function() {
+ var count = 0;
-amplify.subscribe('custom', function(data) {
- count++;
-});
-amplify.subscribe('custom', function(data) {
- count++;
-});
-amplify.publish('custom', triggerData);
+ amplify.subscribe( "custom", function( data ) {
+ count++;
+ } );
+ amplify.subscribe( "custom", function( data ) {
+ count++;
+ } );
+ amplify.publish( "custom", triggerData );
-equal(count, 2);
-});
+ equal( count, 2 );
+} );
// Returning false from a subscription will prevent any additional subscriptions
// from being invoked and will cause amplify.publish to return false.
-test("amplify.publish with two subscribers that return false", function() {
-var count = 0;
+test( "amplify.publish with two subscribers that return false", function() {
+ var count = 0;
-amplify.subscribe('custom', function(data) {
- count++;
- return false;
-});
-amplify.subscribe('custom', function(data) {
- count++;
- return false;
-});
-amplify.publish('custom', triggerData);
+ amplify.subscribe( "custom", function( data ) {
+ count++;
+ return false;
+ } );
+ amplify.subscribe( "custom", function( data ) {
+ count++;
+ return false;
+ } );
+ amplify.publish( "custom", triggerData );
-equal(count, 1);
-});
+ equal( count, 1 );
+} );
View
@@ -1,92 +1,92 @@
-module("jQuery custom events");
+module( "jQuery custom events" );
-test("trigger custom event", function() {
+test( "trigger custom event", function() {
var a = null;
- $(document).bind('custom', function(event, data) {
+ $( document ).bind( "custom", function( event, data ) {
a = data;
- });
- $(document).trigger('custom', triggerData);
+ } );
+ $( document ).trigger( "custom", triggerData );
- deepEqual(a, triggerData);
-});
+ deepEqual( a, triggerData );
+} );
-test("trigger custom event with two subscribers", function() {
+test( "trigger custom event with two subscribers", function() {
var count = 0;
- $("html").bind('custom', function(event, data) {
+ $( "html" ).bind( "custom", function( event, data ) {
count++;
- });
- $("body").bind('custom', function(event, data) {
+ } );
+ $( "body" ).bind( "custom", function( event, data ) {
count++;
- });
- $("body").trigger('custom', triggerData);
+ } );
+ $( "body" ).trigger( "custom", triggerData );
- equal(count, 2);
-});
+ equal( count, 2 );
+} );
-test("trigger custom event with namespace", function() {
+test( "trigger custom event with namespace", function() {
var count = 0, namespaceCount = 0;
- $("html").bind('custom.namespace', function(event, data) {
+ $( "html" ).bind( "custom.namespace", function( event, data ) {
namespaceCount++;
- });
- $("body").bind('custom', function(event, data) {
+ } );
+ $( "body" ).bind( "custom", function( event, data ) {
count++;
- });
- $("body").trigger('custom', triggerData);
- $("body").trigger('custom.namespace', triggerData);
+ } );
+ $( "body" ).trigger( "custom", triggerData );
+ $( "body" ).trigger( "custom.namespace", triggerData );
- equal(count, 1);
- equal(namespaceCount, 2);
-});
+ equal( count, 1 );
+ equal( namespaceCount, 2 );
+} );
-test("trigger custom event with two lateral subscribers that return false", function() {
+test( "trigger custom event with two lateral subscribers that return false", function() {
var count = 0;
- $("body").bind('custom', function(event, data) {
+ $( "body" ).bind( "custom", function( event, data ) {
count++;
return false;
- });
- $("body").bind('custom', function(event, data) {
+ } );
+ $( "body" ).bind( "custom", function( event, data ) {
count++;
return false;
- });
- $("body").trigger('custom', triggerData);
+ } );
+ $( "body" ).trigger( "custom", triggerData );
- equal(count, 2);
-});
+ equal( count, 2 );
+} );
// an event handler can stop the bubbling by returning false from the handler or
// calling the .stopPropagation() method on the event object passed into the event.
-test("trigger custom event with two hierarchical subscribers that return false", function() {
+test( "trigger custom event with two hierarchical subscribers that return false", function() {
var count = 0;
- $("html").bind('custom', function(event, data) {
+ $( "html" ).bind( "custom", function( event, data ) {
count++;
- });
- $("body").bind('custom', function(event, data) {
+ } );
+ $( "body" ).bind( "custom", function( event, data ) {
count++;
return false;
- });
- $("body").trigger('custom', triggerData);
+ } );
+ $( "body" ).trigger( "custom", triggerData );
- equal(count, 1);
-});
+ equal( count, 1 );
+} );
-test("trigger custom event with two hierarchical subscribers that stopPropagation", function() {
+test( "trigger custom event with two hierarchical subscribers that stopPropagation", function() {
var count = 0;
- $("html").bind('custom', function(event, data) {
+ $( "html" ).bind( "custom", function( event, data ) {
count++;
- });
- $("body").bind('custom', function(event, data) {
+ } );
+ $( "body" ).bind( "custom", function( event, data ) {
count++;
event.stopPropagation();
- });
- $("body").trigger('custom', triggerData);
+ } );
+ $( "body" ).trigger( "custom", triggerData );
- equal(count, 1);
-});
+ equal( count, 1 );
+} );

0 comments on commit 97b5929

Please sign in to comment.