Implement expectation test instead of using _removeData. #997

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants
Member

Krinkle commented Oct 17, 2012

No description provided.

Member

Krinkle commented Oct 17, 2012

@gnarf37 @gibson042

Member

Krinkle commented Oct 17, 2012

(note, it fixes some issues, but does currently trigger a few failures from the teardown. per @gnarf37 I'm sharing as-is for now to see what we think about it).

@rwaldron rwaldron and 1 other commented on an outdated diff Oct 17, 2012

test/data/testrunner.js
@@ -156,9 +247,6 @@ function testSubproject( label, url, risTests ) {
// and start()'s the next test.
QUnit.config.testTimeout = 20 * 1000; // 20 seconds
-// Enforce an "expect" argument or expect() call in all test bodies.
-QUnit.config.requireExpects = true;
@Krinkle

Krinkle Oct 17, 2012

Member

Yikes! (copy, paste, revert, move back, forgot a line). Fixing...

@gibson042 gibson042 commented on an outdated diff Oct 17, 2012

test/unit/data.js
dataTests(document);
+});
+
+test("Expando cleanup", function() {
+ var div = document.createElement("div");
+
+ function assertExpandoAbsent(message) {
@gibson042

gibson042 Oct 17, 2012

Member

Missing declarations for actual and expected?

@gibson042 gibson042 commented on an outdated diff Oct 17, 2012

test/unit/data.js
dataTests(document);
+});
+
+test("Expando cleanup", function() {
@gibson042

gibson042 Oct 17, 2012

Member

I'd expect this test to run with checkJqData. Maybe allow QUnit.expectJqData() to set it without adding any specific expectations? Or just QUnit.expectJqData([]), I suppose.

Member

gibson042 commented Oct 17, 2012

This pretty much became The Patch That Ate Wednesday, but I really appreciate your work here. Our test suite will be so much better off as a result.

@Krinkle Krinkle Implement expectation test instead of using _removeData.
* Removed inline usage of QUnit.reset() because it is messing with the
  expectation model as reset does .empty() which does a recursive cleanData
  on everything in #qunit-fixture, so any expectJqData above .reset() would
  fail negatively.

  Instead of calling reset inline, either updated the following assertions to
  take previous assertions' state into account, or broke the test() up into
  2 tests at the point where it would call QUnit.reset.

* After introducing the new memory leak discovery a whole bunch of tests were
  failing as they didn't clean up everything. However I didn't (yet) add
  QUnit.expectJqData calls all over the place because in most if not all of
  these cases it is valid data storage. For example in test "data()", there
  will be an internal data key for "parsedAttrs". This particular test isn't
  intending to test for memory leaks, so therefor I made the new discovery
  system only push failures when the test contains at least 1 call to
  QUnit.expectJqData.

  When not, we'll assume that whatever data is being stored is acceptable
  because the relevant elements still exist in the DOM anyway (QUnit.reset
  will remove the elements and clean up the data automatically).

  I did add a "Always check jQuery.data" mode in the test suite that will
  trigger it everywhere. Maybe one day we'll include a call to everywhere,
  but for now I'm keeping the status quo: Only consider data left in storage
  to be a problem if the test says so ("opt-in").

* Had to move #fx-tests inside the fixture because ".remove()" test would
  otherwise remove stuff permanently and cause random other tests to fail
  as "#hide div" would yield an empty collection.
  (Why wasn't this in the fixture in the first place?)

  As a result moving fx-tests into the fixture a whole bunch of tests failed
  that relied on arbitrary stuff about the document-wide or fixture-wide
  state (e.g. number of divs etc.). So I had to adjust various tests to
  limit their sample data to not be so variable and unlimited...

* Moved out tests for expando cleanup into a separate test.

* Fixed implied global variable 'pass' in effects.js that was causing
  "TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
  uses a global variable "pass = function () {};" ...

* Removed spurious calls to _removeData. The new test exposed various failures
  e.g. where div[0] isn't being assigned any data anyway.
  (queue.js and attributes.js toggleClass).

* Removed spurious clean up at the bottom of test() functions that are
  already covered by the teardown (calling QUnit.reset or removeClass to
  supposedly undo any changes).

* Documented the parentheses-less magic line in toggleClass. It appeared that
  it would always keep the current class name if there was any (since the
  assignment started with "this.className || ...".

  Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
  Only added the comment for now, though I prefer clarity with logical
  operators, I'd rather not face the yayMinPD[1] in this test-related commit.

* Updated QUnit urlConfig to the new format (raw string is deprecated).

* Clean up odd htmlentities in test titles, QUnit escapes this.
  (^\s+test\(.*)(&gt\;) → $1>
  (^\s+test\(.*)(&lt\;) → $1<

[1] jQuery MinJsGz Release Police Department (do the same, download less)
c086643

dmethvin closed this in 36c9ecb Oct 29, 2012

Owner

dmethvin commented Oct 29, 2012

Looks like we have a test failure from this: http://swarm.jquery.org/job/1210

@mescoda mescoda pushed a commit to mescoda/jquery that referenced this pull request Nov 4, 2014

@Krinkle @dmethvin Krinkle + dmethvin Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
  expectation model as reset does .empty() which does a recursive cleanData
  on everything in #qunit-fixture, so any expectJqData above .reset() would
  fail negatively.

  Instead of calling reset inline, either updated the following assertions to
  take previous assertions' state into account, or broke the test() up into
  2 tests at the point where it would call QUnit.reset.

* After introducing the new memory leak discovery a whole bunch of tests were
  failing as they didn't clean up everything. However I didn't (yet) add
  QUnit.expectJqData calls all over the place because in most if not all of
  these cases it is valid data storage. For example in test "data()", there
  will be an internal data key for "parsedAttrs". This particular test isn't
  intending to test for memory leaks, so therefor I made the new discovery
  system only push failures when the test contains at least 1 call to
  QUnit.expectJqData.

  When not, we'll assume that whatever data is being stored is acceptable
  because the relevant elements still exist in the DOM anyway (QUnit.reset
  will remove the elements and clean up the data automatically).

  I did add a "Always check jQuery.data" mode in the test suite that will
  trigger it everywhere. Maybe one day we'll include a call to everywhere,
  but for now I'm keeping the status quo: Only consider data left in storage
  to be a problem if the test says so ("opt-in").

* Had to move #fx-tests inside the fixture because ".remove()" test would
  otherwise remove stuff permanently and cause random other tests to fail
  as "#hide div" would yield an empty collection.
  (Why wasn't this in the fixture in the first place?)

  As a result moving fx-tests into the fixture a whole bunch of tests failed
  that relied on arbitrary stuff about the document-wide or fixture-wide
  state (e.g. number of divs etc.). So I had to adjust various tests to
  limit their sample data to not be so variable and unlimited...

* Moved out tests for expando cleanup into a separate test.

* Fixed implied global variable 'pass' in effects.js that was causing
  "TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
  uses a global variable "pass = function () {};" ...

* Removed spurious calls to _removeData. The new test exposed various failures
  e.g. where div[0] isn't being assigned any data anyway.
  (queue.js and attributes.js toggleClass).

* Removed spurious clean up at the bottom of test() functions that are
  already covered by the teardown (calling QUnit.reset or removeClass to
  supposedly undo any changes).

* Documented the parentheses-less magic line in toggleClass. It appeared that
  it would always keep the current class name if there was any (since the
  assignment started with "this.className || ...".

  Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
  Only added the comment for now, though I prefer clarity with logical
  operators, I'd rather not face the yayMinPD[1] in this test-related commit.

* Updated QUnit urlConfig to the new format (raw string is deprecated).

* Clean up odd htmlentities in test titles, QUnit escapes this.
  (^\s+test\(.*)(&gt\;) → $1>
  (^\s+test\(.*)(&lt\;) → $1<

[1] jQuery MinJsGz Release Police Department (do the same, download less)
e68b4e6

@mescoda mescoda pushed a commit to mescoda/jquery that referenced this pull request Nov 4, 2014

@Krinkle @dmethvin Krinkle + dmethvin Followup to gh-997, decode entities in test names. Close gh-1013. fc50e91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment