Skip to content

Commit

Permalink
Test: Add failing test for fixture attribute leakage.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue authored and trentmwillis committed Jan 17, 2018
1 parent 8dfc4ad commit 4804d6e
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/main/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ if ( typeof document !== "undefined" ) {

QUnit.module( "fixture", function( hooks ) {
var failure = false,
values = [ /* initial value (see unshift below), */ "<b>ar</b>", undefined ],
values = [

/* initial value (see unshift below), */
/* initial value (see unshift below), */
"<b>ar</b>",
undefined
],
originalValue;

hooks.before( function() {
originalValue = QUnit.config.fixture;
values.unshift( originalValue );
values.unshift( originalValue );
} );

hooks.beforeEach( function( assert ) {
Expand Down Expand Up @@ -67,13 +74,25 @@ if ( typeof document !== "undefined" ) {
} );

QUnit.test( "setup", function( assert ) {
assert.equal( values.length, 3, "proper sequence" );
assert.equal( values.length, 4, "proper sequence" );

// setup for next test
document.getElementById( "qunit-fixture" ).innerHTML = "foo";
} );

QUnit.test( "automatically reset", function( assert ) {
assert.fixtureEquals( {
tagName: "div",
attributes: { id: "qunit-fixture" },
content: originalValue
} );
assert.equal( values.length, 3, "proper sequence" );

// setup for next test
document.getElementById( "qunit-fixture" ).setAttribute( "data-foo", "blah" );
} );

QUnit.test( "automatically reset after attribute value mutation", function( assert ) {
assert.fixtureEquals( {
tagName: "div",
attributes: { id: "qunit-fixture" },
Expand Down

0 comments on commit 4804d6e

Please sign in to comment.