Skip to content

Commit

Permalink
Assert: Clone actual steps array to avoid passing internal reference
Browse files Browse the repository at this point in the history
  • Loading branch information
trentmwillis committed Mar 1, 2018
1 parent f7c7ec4 commit b16b16e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class Assert {

// Verifies the steps in a test match a given array of string values
verifySteps( steps, message ) {
this.deepEqual( this.test.steps, steps, message );

// Since the steps array is just string values, we can clone with slice
const actualStepsClone = this.test.steps.slice();
this.deepEqual( actualStepsClone, steps, message );
this.test.steps.length = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion test/main/assert/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ QUnit.module( "assert.verifySteps value reference", function() {
assert.verifySteps( [ "step one", "step two" ], "verification-assertion" );
} );

QUnit.todo( "steps array should not be reset in logging function", function( assert ) {
QUnit.test( "steps array should not be reset in logging function", function( assert ) {
const result = loggedAssertions[ "verification-assertion" ].actual;
assert.deepEqual( result, [ "step one", "step two" ] );
} );
Expand Down

0 comments on commit b16b16e

Please sign in to comment.