Browse Source

Better naming for callback invocation counter

v1.x
Raul Ochoa 9 years ago
parent
commit
e7621672f9
  1. 24
      test/image.test.js

24
test/image.test.js

@ -38,10 +38,10 @@ describe('Image', function () {
it('test Image#onload multiple times', function() { it('test Image#onload multiple times', function() {
var img = new Image var img = new Image
, n = 0; , onloadCalled = 0;
img.onload = function() { img.onload = function() {
++n; ++onloadCalled;
}; };
img.src = png_checkers; img.src = png_checkers;
@ -56,14 +56,14 @@ describe('Image', function () {
assert.strictEqual(320, img.width); assert.strictEqual(320, img.width);
assert.strictEqual(320, img.height); assert.strictEqual(320, img.height);
assert.equal(n, 2); assert.equal(onloadCalled, 2);
n = 0; onloadCalled = 0;
img.onload = function() { img.onload = function() {
++n; ++onloadCalled;
}; };
img.src = png_clock; img.src = png_clock;
assert.equal(n, 1); assert.equal(onloadCalled, 1);
}); });
it('Image#onerror', function () { it('Image#onerror', function () {
@ -98,7 +98,7 @@ describe('Image', function () {
it('test Image#onerror multiple calls', function() { it('test Image#onerror multiple calls', function() {
var img = new Image var img = new Image
, n = 0; , onloadCalled = 0;
img.onload = function() { img.onload = function() {
@ -106,7 +106,7 @@ describe('Image', function () {
}; };
img.onerror = function() { img.onerror = function() {
++n; ++onloadCalled;
}; };
img.src = png_clock + 's1'; img.src = png_clock + 's1';
@ -115,15 +115,15 @@ describe('Image', function () {
img.src = png_clock + 's2'; img.src = png_clock + 's2';
assert.equal(img.src, png_clock + 's2'); assert.equal(img.src, png_clock + 's2');
assert.equal(n, 2); assert.equal(onloadCalled, 2);
n = 0; onloadCalled = 0;
img.onerror = function() { img.onerror = function() {
++n; ++onloadCalled;
}; };
img.src = png_clock + 's3'; img.src = png_clock + 's3';
assert.equal(img.src, png_clock + 's3'); assert.equal(img.src, png_clock + 's3');
assert.equal(n, 1); assert.equal(onloadCalled, 1);
}); });
it('Image#{width,height}', function () { it('Image#{width,height}', function () {

Loading…
Cancel
Save