From 1e76291ada7040a0fdd9f96979e26f782b82bf2d Mon Sep 17 00:00:00 2001 From: Mark Goldsmith Date: Wed, 19 Feb 2020 08:51:03 -0500 Subject: [DEV-7060] Set document in constructor of ElementStyler --- test/ui/ElementStylerTest.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/ui/ElementStylerTest.js b/test/ui/ElementStylerTest.js index e7d16af..30812a8 100644 --- a/test/ui/ElementStylerTest.js +++ b/test/ui/ElementStylerTest.js @@ -115,10 +115,15 @@ describe( 'ui.ElementStyler', () => { it( "determines the correct element id for " + name, () => { - // Stub all objects - $ = sinon.stub(); - jQuery = sinon.stub(); - document = sinon.stub(); + // Stub document and jQuery calls + $ = sinon.stub(); + jQuery = sinon.stub(); + + const document = { + getElementById: sinon.stub() + }; + + jQuery.withArgs( 'body' ).returns( { context: document } ); const sut = Sut( jQuery ); @@ -136,12 +141,11 @@ describe( 'ui.ElementStyler', () => html: html, }; - document.getElementById = sinon.stub(); document.getElementById.returns( node ); sut.getWidgetByName( name, index, null, context ); - const actual_id = document.getElementById.getCall(0).args[0]; + const actual_id = document.getElementById.getCall( 0 ).args[ 0 ]; expect( actual_id ) .to.equal( expected_id ); -- cgit v1.2.1