summaryrefslogtreecommitdiffstats
path: root/test/jquery-impromptu_spec.js
diff options
context:
space:
mode:
authorTrent Richardson <trentdrichardson@gmail.com>2014-09-26 17:00:36 -0400
committerTrent Richardson <trentdrichardson@gmail.com>2014-09-26 17:00:36 -0400
commit53dd7365800b23d34bd91e8236c7c79f04c07d17 (patch)
treed9097f16b86efeb41bcb6cb50a5dc44774f602a4 /test/jquery-impromptu_spec.js
parente7eb89886a38cb38c2cade745eeeaead59202cc8 (diff)
downloadjQuery-Impromptu-53dd7365800b23d34bd91e8236c7c79f04c07d17.zip
jQuery-Impromptu-53dd7365800b23d34bd91e8236c7c79f04c07d17.tar.gz
jQuery-Impromptu-53dd7365800b23d34bd91e8236c7c79f04c07d17.tar.bz2
Begin upgrade to jasmine 2
Diffstat (limited to 'test/jquery-impromptu_spec.js')
-rw-r--r--test/jquery-impromptu_spec.js285
1 files changed, 130 insertions, 155 deletions
diff --git a/test/jquery-impromptu_spec.js b/test/jquery-impromptu_spec.js
index 11cadeb..ef09663 100644
--- a/test/jquery-impromptu_spec.js
+++ b/test/jquery-impromptu_spec.js
@@ -590,73 +590,67 @@ describe('jquery-impromptu', function() {
// ====================================================================================
describe('impromptu:loaded', function(){
+ describe('running through jquery event binding', function(){
+ var spyEventCalled;
- it('should fire event', function(){
- var spyEventCalled = false;
-
- $('body').on('impromptu:loaded', '.jqibox', function(){ spyEventCalled = true; });
- $.prompt(states);
-
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
+ beforeEach(function(done){
+ spyEventCalled = false;
+ $('body').on('impromptu:loaded', '.jqibox', function(){ spyEventCalled=true; done() });
+ $.prompt(states);
+ });
- runs(function(){
+ it('should fire event', function(){
expect(spyEventCalled).toBe(true);
});
});
- it('should allow event function as option parameter', function(){
- var spyEventCalled = false;
-
- $.prompt(states, { loaded: function(){ spyEventCalled = true; } });
+ describe('passing loaded event through as option', function(){
+ var spyEventCalled;
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
+ beforeEach(function(done){
+ spyEventCalled = false;
+ $.prompt(states, { loaded: function(){ spyEventCalled = true; done(); } });
+ });
- runs(function(){
+ it('should allow event function as option parameter', function(){
expect(spyEventCalled).toBe(true);
});
});
-
});
// ====================================================================================
describe('impromptu:close', function(){
- it('should fire event', function(){
- var spyEventCalled = false;
-
- $('body').on('impromptu:close', '.jqibox', function(){ spyEventCalled = true; });
- $.prompt(states, {
- loaded: function(){
- $.prompt.close();
- }
+ describe('running through jquery event binding', function(){
+ var spyEventCalled;
+
+ beforeEach(function(done){
+ spyEventCalled = false;
+ $('body').on('impromptu:close', '.jqibox', function(){ spyEventCalled=true; done() });
+ $.prompt(states, {
+ loaded: function(){
+ $.prompt.close();
+ }
+ });
});
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
-
- runs(function(){
+ it('should fire event', function(){
expect(spyEventCalled).toBe(true);
});
});
- it('should allow event function as option parameter', function(){
- var spyEventCalled = false;
+ describe('passing loaded event through as option', function(){
+ var spyEventCalled;
- $.prompt(states, {
- loaded: function(){ $.prompt.close(); },
- close: function(){ spyEventCalled = true; }
+ beforeEach(function(done){
+ spyEventCalled = false;
+ $.prompt(states, {
+ loaded: function(){ $.prompt.close(); },
+ close: function(){ spyEventCalled = true; done(); }
+ });
});
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
-
- runs(function(){
+ it('should allow event function as option parameter', function(){
expect(spyEventCalled).toBe(true);
});
});
@@ -666,44 +660,45 @@ describe('jquery-impromptu', function() {
// ====================================================================================
describe('impromptu:statechanging', function(){
- it('should fire event', function(){
- var spyEventCalled = false;
+ describe('running through jquery event binding', function(){
+ var spyEventCalled;
- $('body').on('impromptu:statechanging', '.jqibox', function(){ spyEventCalled = true; });
- $.prompt(states, {
- loaded: function(){
- $.prompt.goToState('s2');
- }
- });
+ beforeEach(function(done){
+ spyEventCalled = false;
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
+ $('body').on('impromptu:statechanging', '.jqibox', function(){ spyEventCalled = true; done(); });
+ $.prompt(states, {
+ loaded: function(){
+ $.prompt.goToState('s2');
+ }
+ });
+ });
- runs(function(){
+ it('should fire event', function(){
expect(spyEventCalled).toBe(true);
});
});
- it('should allow event function as option parameter', function(){
- var spyEventCalled = false;
+ describe('passing loaded event through as option', function(){
+ var spyEventCalled;
- $.prompt(states, {
- loaded: function(){
- $.prompt.goToState('s2');
- },
- statechanging: function(){ spyEventCalled = true; }
- });
+ beforeEach(function(done){
+ spyEventCalled = false;
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
+ $.prompt(states, {
+ loaded: function(){
+ $.prompt.goToState('s2');
+ },
+ statechanging: function(){ spyEventCalled = true; done(); }
+ });
+ });
- runs(function(){
+ it('should allow event function as option parameter', function(){
expect(spyEventCalled).toBe(true);
});
});
+
it('should allow preventDefault', function(){
var spyEvent = spyOnEvent('body', 'impromptu:statechanging');
@@ -725,40 +720,40 @@ describe('jquery-impromptu', function() {
// ====================================================================================
describe('impromptu:statechanged', function(){
- it('should fire event', function(){
- var spyEventCalled = false;
+ describe('running through jquery event binding', function(){
+ var spyEventCalled;
- $('body').on('impromptu:statechanged', '.jqibox', function(){ spyEventCalled = true; });
- $.prompt(states, {
- loaded: function(){
- $.prompt.goToState('s2');
- }
- });
+ beforeEach(function(done){
+ spyEventCalled = false;
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
+ $('body').on('impromptu:statechanged', '.jqibox', function(){ spyEventCalled = true; done(); });
+ $.prompt(states, {
+ loaded: function(){
+ $.prompt.goToState('s2');
+ }
+ });
+ });
- runs(function(){
+ it('should fire event', function(){
expect(spyEventCalled).toBe(true);
});
});
- it('should allow event function as option parameter', function(){
- var spyEventCalled = false;
+ describe('passing loaded event through as option', function(){
+ var spyEventCalled;
- $.prompt(states, {
- loaded: function(){
- $.prompt.goToState('s2');
- },
- statechanged: function(){ spyEventCalled = true; }
- });
+ beforeEach(function(done){
+ spyEventCalled = false;
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
+ $.prompt(states, {
+ loaded: function(){
+ $.prompt.goToState('s2');
+ },
+ statechanged: function(){ spyEventCalled = true; done(); }
+ });
+ });
- runs(function(){
+ it('should allow event function as option parameter', function(){
expect(spyEventCalled).toBe(true);
});
});
@@ -768,96 +763,76 @@ describe('jquery-impromptu', function() {
// ====================================================================================
describe('impromptu:submit', function(){
- it('should fire event', function(){
- var spyEventCalled = false;
+ describe('running through jquery event binding', function(){
+ var spyEventCalled;
- $('body').on('impromptu:submit', '.jqibox', function(){ spyEventCalled = true; });
- $.prompt(states, {
- loaded: function(){
- $.prompt.getState('s1').find('.jqibutton:first').click();
- }
- });
+ beforeEach(function(done){
+ spyEventCalled = false;
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
+ $('body').on('impromptu:submit', '.jqibox', function(){ spyEventCalled = true; done(); });
+ $.prompt(states, {
+ loaded: function(){
+ $.prompt.getState('s1').find('.jqibutton:first').click();
+ }
+ });
+ });
- runs(function(){
+ it('should fire event', function(){
expect(spyEventCalled).toBe(true);
});
});
- it('should allow event function as option parameter if string message', function(){
- var spyEventCalled = false;
- $.prompt('Test message', {
- loaded: function(){
- $('.jqibutton:first').click();
- },
- submit: function(){ spyEventCalled = true; }
- });
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
+ describe('passing loaded event through as option if string message', function(){
+ var spyEventCalled;
- runs(function(){
- expect(spyEventCalled).toBe(true);
- });
- });
+ beforeEach(function(done){
+ spyEventCalled = false;
- it('should detect button clicked', function(){
- var spyEventCalled = false,
- btnClicked,
- msgReturned,
- formVals;
-
- $('body').on('impromptu:submit', '.jqibox', function(e,v,m,f){
- btnClicked = v;
- msgReturned = m;
- formVals = f;
- spyEventCalled = true;
- });
-
- $.prompt(states, {
- loaded: function(){
- $.prompt.getState('s1').find('#jqi_s1_buttoncancel').click();
- }
+ $.prompt('Test message', {
+ loaded: function(){
+ $('.jqibutton:first').click();
+ },
+ submit: function(){ spyEventCalled = true; done(); }
+ });
});
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
-
- runs(function(){
- expect(btnClicked).toBe(false);
+ it('should allow event function as option parameter', function(){
+ expect(spyEventCalled).toBe(true);
});
});
- it('should pass the state message', function(){
+
+ describe('should detect button clicked', function(){
var spyEventCalled = false,
btnClicked,
msgReturned,
formVals;
- $('body').on('impromptu:submit', '.jqibox', function(e,v,m,f){
- btnClicked = v;
- msgReturned = m;
- formVals = f;
- spyEventCalled = true;
+ beforeEach(function(done){
+ spyEventCalled = false;
+
+ $('body').on('impromptu:submit', '.jqibox', function(e,v,m,f){
+ btnClicked = v;
+ msgReturned = m;
+ formVals = f;
+ spyEventCalled = true;
+ done();
+ });
+
+ $.prompt(states, {
+ loaded: function(){
+ $.prompt.getState('s1').find('#jqi_s1_buttoncancel').click();
+ }
+ });
});
- $.prompt(states, {
- loaded: function(){
- $.prompt.getState('s1').find('#jqi_s1_buttoncancel').click();
- }
+ it('should detect button', function(){
+ expect(btnClicked).toBe(false);
});
- waitsFor(function(){
- return spyEventCalled;
- }, 'event should have been called',maxWaitTime);
-
- runs(function(){
+ it('should pass the state message', function(){
expect(msgReturned).toBe('.jqimessage');
});
});