aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/jQueryPatchSpec.js4
-rw-r--r--test/jqLiteSpec.js88
-rw-r--r--test/ng/directive/formSpec.js2
-rw-r--r--test/ng/locationSpec.js16
-rw-r--r--test/ngMock/angular-mocksSpec.js6
-rw-r--r--test/ngScenario/ApplicationSpec.js2
-rw-r--r--test/ngScenario/dslSpec.js4
-rw-r--r--test/testabilityPatch.js2
8 files changed, 74 insertions, 50 deletions
diff --git a/test/jQueryPatchSpec.js b/test/jQueryPatchSpec.js
index 0680a0c3..0efbb8d1 100644
--- a/test/jQueryPatchSpec.js
+++ b/test/jQueryPatchSpec.js
@@ -14,8 +14,8 @@ if (window.jQuery) {
spy1 = jasmine.createSpy('span1.$destroy');
spy2 = jasmine.createSpy('span2.$destroy');
doc = $('<div><span class=first>abc</span><span class=second>xyz</span></div>');
- doc.find('span.first').bind('$destroy', spy1);
- doc.find('span.second').bind('$destroy', spy2);
+ doc.find('span.first').on('$destroy', spy1);
+ doc.find('span.second').on('$destroy', spy2);
});
afterEach(function() {
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index f121e1a0..f6630536 100644
--- a/test/jqLiteSpec.js
+++ b/test/jqLiteSpec.js
@@ -268,7 +268,7 @@ describe('jqLite', function() {
it('should emit $destroy event if element removed via remove()', function() {
var log = '';
var element = jqLite(a);
- element.bind('$destroy', function() {log+= 'destroy;';});
+ element.on('$destroy', function() {log+= 'destroy;';});
element.remove();
expect(log).toEqual('destroy;');
});
@@ -276,7 +276,7 @@ describe('jqLite', function() {
it('should emit $destroy event if an element is removed via html()', inject(function(log) {
var element = jqLite('<div><span>x</span></div>');
- element.find('span').bind('$destroy', log.fn('destroyed'));
+ element.find('span').on('$destroy', log.fn('destroyed'));
element.html('');
@@ -343,7 +343,7 @@ describe('jqLite', function() {
span = div.find('span'),
log = '';
- span.bind('click', function() { log+= 'click;'});
+ span.on('click', function() { log+= 'click;'});
browserTrigger(span);
expect(log).toEqual('click;');
@@ -705,7 +705,7 @@ describe('jqLite', function() {
});
- describe('bind', function() {
+ describe('on', function() {
it('should bind to window on hashchange', function() {
if (jqLite.fn) return; // don't run in jQuery
var eventFn;
@@ -727,7 +727,7 @@ describe('jqLite', function() {
detachEvent: noop
};
var log;
- var jWindow = jqLite(window).bind('hashchange', function() {
+ var jWindow = jqLite(window).on('hashchange', function() {
log = 'works!';
});
eventFn({type: 'hashchange'});
@@ -739,7 +739,7 @@ describe('jqLite', function() {
it('should bind to all elements and return functions', function() {
var selected = jqLite([a, b]);
var log = '';
- expect(selected.bind('click', function() {
+ expect(selected.on('click', function() {
log += 'click on: ' + jqLite(this).text() + ';';
})).toEqual(selected);
browserTrigger(a, 'click');
@@ -752,8 +752,8 @@ describe('jqLite', function() {
var elm = jqLite(a),
callback = jasmine.createSpy('callback');
- elm.bind('click keypress', callback);
- elm.bind('click', callback);
+ elm.on('click keypress', callback);
+ elm.on('click', callback);
browserTrigger(a, 'click');
expect(callback).toHaveBeenCalled();
@@ -767,7 +767,7 @@ describe('jqLite', function() {
it('should set event.target on IE', function() {
var elm = jqLite(a);
- elm.bind('click', function(event) {
+ elm.on('click', function(event) {
expect(event.target).toBe(a);
});
@@ -775,7 +775,7 @@ describe('jqLite', function() {
});
it('should have event.isDefaultPrevented method', function() {
- jqLite(a).bind('click', function(e) {
+ jqLite(a).on('click', function(e) {
expect(function() {
expect(e.isDefaultPrevented()).toBe(false);
e.preventDefault();
@@ -796,11 +796,11 @@ describe('jqLite', function() {
sibling = root.find('ul');
child = parent.find('span');
- parent.bind('mouseenter', function() { log += 'parentEnter;'; });
- parent.bind('mouseleave', function() { log += 'parentLeave;'; });
+ parent.on('mouseenter', function() { log += 'parentEnter;'; });
+ parent.on('mouseleave', function() { log += 'parentLeave;'; });
- child.bind('mouseenter', function() { log += 'childEnter;'; });
- child.bind('mouseleave', function() { log += 'childLeave;'; });
+ child.on('mouseenter', function() { log += 'childEnter;'; });
+ child.on('mouseleave', function() { log += 'childLeave;'; });
});
afterEach(function() {
@@ -854,6 +854,30 @@ describe('jqLite', function() {
});
});
+
+ // Only run this test for jqLite and not normal jQuery
+ if ( _jqLiteMode ) {
+ it('should throw an error if eventData or a selector is passed', function() {
+ var elm = jqLite(a),
+ anObj = {},
+ aString = '',
+ aValue = 45,
+ callback = function() {};
+
+ expect(function() {
+ elm.on('click', anObj, callback);
+ }).toThrow();
+
+ expect(function() {
+ elm.on('click', null, aString, callback);
+ }).toThrow();
+
+ expect(function() {
+ elm.on('click', aValue, callback);
+ }).toThrow();
+
+ });
+ }
});
@@ -861,9 +885,9 @@ describe('jqLite', function() {
it('should do nothing when no listener was registered with bound', function() {
var aElem = jqLite(a);
- aElem.unbind();
- aElem.unbind('click');
- aElem.unbind('click', function() {});
+ aElem.off();
+ aElem.off('click');
+ aElem.off('click', function() {});
});
@@ -872,8 +896,8 @@ describe('jqLite', function() {
clickSpy = jasmine.createSpy('click'),
mouseoverSpy = jasmine.createSpy('mouseover');
- aElem.bind('click', clickSpy);
- aElem.bind('mouseover', mouseoverSpy);
+ aElem.on('click', clickSpy);
+ aElem.on('mouseover', mouseoverSpy);
browserTrigger(a, 'click');
expect(clickSpy).toHaveBeenCalledOnce();
@@ -883,7 +907,7 @@ describe('jqLite', function() {
clickSpy.reset();
mouseoverSpy.reset();
- aElem.unbind();
+ aElem.off();
browserTrigger(a, 'click');
expect(clickSpy).not.toHaveBeenCalled();
@@ -897,8 +921,8 @@ describe('jqLite', function() {
clickSpy = jasmine.createSpy('click'),
mouseoverSpy = jasmine.createSpy('mouseover');
- aElem.bind('click', clickSpy);
- aElem.bind('mouseover', mouseoverSpy);
+ aElem.on('click', clickSpy);
+ aElem.on('mouseover', mouseoverSpy);
browserTrigger(a, 'click');
expect(clickSpy).toHaveBeenCalledOnce();
@@ -908,7 +932,7 @@ describe('jqLite', function() {
clickSpy.reset();
mouseoverSpy.reset();
- aElem.unbind('click');
+ aElem.off('click');
browserTrigger(a, 'click');
expect(clickSpy).not.toHaveBeenCalled();
@@ -917,7 +941,7 @@ describe('jqLite', function() {
mouseoverSpy.reset();
- aElem.unbind('mouseover');
+ aElem.off('mouseover');
browserTrigger(a, 'mouseover');
expect(mouseoverSpy).not.toHaveBeenCalled();
});
@@ -928,8 +952,8 @@ describe('jqLite', function() {
clickSpy1 = jasmine.createSpy('click1'),
clickSpy2 = jasmine.createSpy('click2');
- aElem.bind('click', clickSpy1);
- aElem.bind('click', clickSpy2);
+ aElem.on('click', clickSpy1);
+ aElem.on('click', clickSpy2);
browserTrigger(a, 'click');
expect(clickSpy1).toHaveBeenCalledOnce();
@@ -938,7 +962,7 @@ describe('jqLite', function() {
clickSpy1.reset();
clickSpy2.reset();
- aElem.unbind('click', clickSpy1);
+ aElem.off('click', clickSpy1);
browserTrigger(a, 'click');
expect(clickSpy1).not.toHaveBeenCalled();
@@ -946,7 +970,7 @@ describe('jqLite', function() {
clickSpy2.reset();
- aElem.unbind('click', clickSpy2);
+ aElem.off('click', clickSpy2);
browserTrigger(a, 'click');
expect(clickSpy2).not.toHaveBeenCalled();
});
@@ -1159,9 +1183,9 @@ describe('jqLite', function() {
clickSpy1 = jasmine.createSpy('clickSpy1'),
clickSpy2 = jasmine.createSpy('clickSpy2');
- element.bind('poke', pokeSpy);
- element.bind('click', clickSpy1);
- element.bind('click', clickSpy2);
+ element.on('poke', pokeSpy);
+ element.on('click', clickSpy1);
+ element.on('click', clickSpy2);
expect(pokeSpy).not.toHaveBeenCalled();
expect(clickSpy1).not.toHaveBeenCalled();
@@ -1185,7 +1209,7 @@ describe('jqLite', function() {
pokeSpy = jasmine.createSpy('poke'),
event;
- element.bind('click', pokeSpy);
+ element.on('click', pokeSpy);
element.triggerHandler('click');
event = pokeSpy.mostRecentCall.args[0];
diff --git a/test/ng/directive/formSpec.js b/test/ng/directive/formSpec.js
index 0e3695cd..f6173414 100644
--- a/test/ng/directive/formSpec.js
+++ b/test/ng/directive/formSpec.js
@@ -247,7 +247,7 @@ describe('form', function() {
});
doc = $compile('<form action="some.py"></form>')(scope);
- doc.bind('submit', callback);
+ doc.on('submit', callback);
browserTrigger(doc, 'submit');
expect(callback).toHaveBeenCalledOnce();
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js
index 9e4b3bd6..2bce3e64 100644
--- a/test/ng/locationSpec.js
+++ b/test/ng/locationSpec.js
@@ -7,7 +7,7 @@ describe('$location', function() {
afterEach(function() {
// link rewriting used in html5 mode on legacy browsers binds to document.onClick, so we need
// to clean this up after each test.
- jqLite(document).unbind('click');
+ jqLite(document).off('click');
});
describe('NewUrl', function() {
@@ -770,7 +770,7 @@ describe('$location', function() {
originalBrowser = $browser.url();
// we have to prevent the default operation, as we need to test absolute links (http://...)
// and navigating to these links would kill jstd
- $rootElement.bind('click', function(e) {
+ $rootElement.on('click', function(e) {
lastEventPreventDefault = e.isDefaultPrevented();
e.preventDefault();
});
@@ -825,7 +825,7 @@ describe('$location', function() {
jqLite(link).
attr('href', 'http://host.com/base/foo').
- bind('click', function(e) { e.preventDefault(); });
+ on('click', function(e) { e.preventDefault(); });
browserTrigger(link, 'click');
expect($browser.url()).toBe('http://host.com/base/');
}
@@ -1116,11 +1116,11 @@ describe('$location', function() {
var base, clickHandler;
module(function($provide) {
$provide.value('$rootElement', {
- bind: function(event, handler) {
+ on: function(event, handler) {
expect(event).toEqual('click');
clickHandler = handler;
},
- unbind: noop
+ off: noop
});
return function($browser) {
$browser.url(base = 'http://server/');
@@ -1146,11 +1146,11 @@ describe('$location', function() {
var base, clickHandler;
module(function($provide) {
$provide.value('$rootElement', {
- bind: function(event, handler) {
+ on: function(event, handler) {
expect(event).toEqual('click');
clickHandler = handler;
},
- unbind: angular.noop
+ off: angular.noop
});
return function($browser) {
$browser.url(base = 'http://server/');
@@ -1180,7 +1180,7 @@ describe('$location', function() {
$rootElement.html('<button></button>');
var button = $rootElement.find('button');
- button.bind('click', function() {
+ button.on('click', function() {
button.remove();
});
browserTrigger(button, 'click');
diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js
index 220f8e58..3f82ac57 100644
--- a/test/ngMock/angular-mocksSpec.js
+++ b/test/ngMock/angular-mocksSpec.js
@@ -425,9 +425,9 @@ describe('ngMock', function() {
// through the code makes the test pass. Viva IE!!!
angular.element(document.body).append(div)
- div.bind('click', function() { log += 'click1;'});
- div.bind('click', function() { log += 'click2;'});
- div.bind('mousemove', function() { log += 'mousemove;'});
+ div.on('click', function() { log += 'click1;'});
+ div.on('click', function() { log += 'click2;'});
+ div.on('mousemove', function() { log += 'mousemove;'});
browserTrigger(div, 'click');
browserTrigger(div, 'mousemove');
diff --git a/test/ngScenario/ApplicationSpec.js b/test/ngScenario/ApplicationSpec.js
index cb9fb478..c5ef30fc 100644
--- a/test/ngScenario/ApplicationSpec.js
+++ b/test/ngScenario/ApplicationSpec.js
@@ -17,7 +17,7 @@ describe('angular.scenario.Application', function() {
afterEach(function() {
- _jQuery('iframe').unbind(); // cleanup any leftover onload handlers
+ _jQuery('iframe').off(); // cleanup any leftover onload handlers
document.body.innerHTML = '';
});
diff --git a/test/ngScenario/dslSpec.js b/test/ngScenario/dslSpec.js
index d89d6ebf..642e2d37 100644
--- a/test/ngScenario/dslSpec.js
+++ b/test/ngScenario/dslSpec.js
@@ -306,7 +306,7 @@ describe("angular.scenario.dsl", function() {
elm = jqLite('<a href="#foo"></a>');
doc.append(elm);
- elm.bind('click', function(event) {
+ elm.on('click', function(event) {
event.preventDefault();
});
@@ -338,7 +338,7 @@ describe("angular.scenario.dsl", function() {
elm = jqLite('<a href="#foo"></a>');
doc.append(elm);
- elm.bind('dblclick', function(event) {
+ elm.on('dblclick', function(event) {
event.preventDefault();
});
diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js
index dbb80f60..278631f1 100644
--- a/test/testabilityPatch.js
+++ b/test/testabilityPatch.js
@@ -106,7 +106,7 @@ function dealoc(obj) {
}
function cleanup(element) {
- element.unbind().removeData();
+ element.off().removeData();
for ( var i = 0, children = element.contents() || []; i < children.length; i++) {
cleanup(angular.element(children[i]));
}