Note that there are some explanatory texts on larger screens.

plurals
  1. PODojo widget variable reference still held after doh test
    primarykey
    data
    text
    <p>I've been creating some tests for my Dojo widget to check that boolean flags are being set correctly. However, I've found that since I have altered my constructor to pass in an object, previously ran tests seem to affect the subsequent tests.</p> <p>I've tried destroying the widget in the tear down methods, but whatever I seem to do, the value persists.</p> <p>Can anyone suggest what I might be doing wrong?</p> <p>My widget code:</p> <pre><code>var showControls = true; return declare([WidgetBase, TemplatedMixin, _WidgetsInTemplateMixin], { templateString: template, constructor: function (params) { this.showControls = (typeof params.showControls === "undefined" || typeof params.showControls != "boolean") ? this.showControls : params.showControls; } }); </code></pre> <p>My test class is:</p> <pre><code>var customWidget; doh.register("Test controls", [ { name: "Test controls are not visible when set in constructor", runTest: function() { var params = { showControls: false }; customWidget = new CustomWidget(params); doh.assertFalse(customWidget.getShowControls()); } }, { name: "Test controls are visible when set in constructor with string instead of boolean", runTest: function() { var params = { showControls: "wrong" }; customWidget= new CustomWidget(params); doh.assertTrue(customWidget.getShowControls()); } } ]); </code></pre> <p>So, the first test passes, as showControls is set to false, however the 2nd test attempts to create a new instance, in which the constructor will check that the value is a boolean. When I debug this however, it thinks showControls starts out as 'false', not true.</p> <p>Any clues?!</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload