Skip to content
Permalink
Browse files

Enforce style in test/unit/callbacks.js. jquery/2012-dev-summit#56

  • Loading branch information...
Erick Ruiz de Chavez authored and rwaldron committed Oct 16, 2012
1 parent f47e3da commit e2ff2b11207b7fce50d53fe6435b44b244e96523
Showing with 27 additions and 22 deletions.
  1. +27 −22 test/unit/callbacks.js
@@ -1,4 +1,6 @@
module("callbacks", { teardown: moduleTeardown });
module( "callbacks", {
teardown: moduleTeardown
});

(function() {

@@ -8,9 +10,9 @@ var output,
output += string;
};
},
outputA = addToOutput( "A" ),
outputB = addToOutput( "B" ),
outputC = addToOutput( "C" ),
outputA = addToOutput("A"),
outputB = addToOutput("B"),
outputC = addToOutput("C"),
tests = {
"": "XABC X XABCABCC X XBB X XABA X XX",
"once": "XABC X X X X X XABA X XX",
@@ -56,7 +58,10 @@ jQuery.each( tests, function( strFlags, resultString ) {

jQuery.each( filters, function( filterLabel, filter ) {

jQuery.each( { "string": strFlags, "object": objectFlags }, function( flagsTypes, flags ) {
jQuery.each({
"string": strFlags,
"object": objectFlags
}, function( flagsTypes, flags ) {

test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function() {

@@ -75,7 +80,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
cblist.add(function( str ) {
output += str;
});
cblist.fire( "A" );
cblist.fire("A");
strictEqual( output, "XA", "Basic binding and firing" );
strictEqual( cblist.fired(), true, ".fired() detects firing" );
output = "X";
@@ -84,7 +89,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
output += str;
});
strictEqual( output, "X", "Adding a callback after disabling" );
cblist.fire( "A" );
cblist.fire("A");
strictEqual( output, "X", "Firing after disabling" );

// Basic binding and firing (context, arguments)
@@ -127,23 +132,23 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Locking
output = "X";
cblist = jQuery.Callbacks( flags );
cblist.add( function( str ) {
cblist.add(function( str ) {
output += str;
});
cblist.lock();
cblist.add( function( str ) {
cblist.add(function( str ) {
output += str;
});
cblist.fire( "A" );
cblist.add( function( str ) {
cblist.fire("A");
cblist.add(function( str ) {
output += str;
});
strictEqual( output, "X", "Lock early" );

// Ordering
output = "X";
cblist = jQuery.Callbacks( flags );
cblist.add( function() {
cblist.add(function() {
cblist.add( outputC );
outputA();
}, outputB );
@@ -152,7 +157,7 @@ jQuery.each( tests, function( strFlags, resultString ) {

// Add and fire again
output = "X";
cblist.add( function() {
cblist.add(function() {
cblist.add( outputC );
outputA();
}, outputB );
@@ -165,23 +170,23 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Multiple fire
output = "X";
cblist = jQuery.Callbacks( flags );
cblist.add( function( str ) {
cblist.add(function( str ) {
output += str;
} );
cblist.fire( "A" );
});
cblist.fire("A");
strictEqual( output, "XA", "Multiple fire (first fire)" );
output = "X";
cblist.add( function( str ) {
cblist.add(function( str ) {
output += str;
} );
});
strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
output = "X";
cblist.fire( "B" );
cblist.fire("B");
strictEqual( output, results.shift(), "Multiple fire (second fire)" );
output = "X";
cblist.add( function( str ) {
cblist.add(function( str ) {
output += str;
} );
});
strictEqual( output, results.shift(), "Multiple fire (second new callback)" );

// Return false
@@ -239,7 +244,7 @@ test( "jQuery.Callbacks.fireWith - arguments are copied", function() {
expect( 1 );

var cb = jQuery.Callbacks( "memory" ),

This comment has been minimized.

Copy link
@mikesherov

mikesherov Oct 16, 2012

Member

("memory")

This comment has been minimized.

Copy link
@rwaldron

rwaldron Oct 16, 2012

Member

@erickrdch ^^^

This comment has been minimized.

Copy link
@eruizdechavez

eruizdechavez Oct 16, 2012

Contributor

Got it... update in a bit ;)

args = [ "hello" ];
args = ["hello"];

cb.fireWith( null, args );
args[ 0 ] = "world";

0 comments on commit e2ff2b1

Please sign in to comment.
You can’t perform that action at this time.