Skip to content

Commit

Permalink
Test .removeFolder().
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy committed Dec 23, 2017
1 parent 76c8085 commit 59f685b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/dat/gui/GUI.js
Expand Up @@ -640,9 +640,9 @@ common.extend(

// Do we have saved appearance data for this folder?
if (this.load && // Anything loaded?
this.load.folders && // Was my parent a dead-end?
this.load.folders[folder.name]) {
delete this.load.folders[folder.name];
this.load.folders && // Was my parent a dead-end?
this.load.folders[folder.name]) {
delete this.load.folders[folder.name];
}

const _this = this;
Expand Down
52 changes: 33 additions & 19 deletions tests/index.html
Expand Up @@ -6,7 +6,7 @@
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen"/>
<script type="text/javascript" src="qunit.js"></script>
<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript" src="../build/dat.gui.js"></script>
<script type="text/javascript">

Expand Down Expand Up @@ -421,23 +421,23 @@
});

function match(a, b, msg) {

for (var i in b) {
if (b[i] !== b[i]) {
ok(a[i] !== a[i], msg)
} else {
equal(b[i], a[i], msg);
}
}

}

function equalish(a, b, tolerance, label) {
return ok(Math.abs(a - b) < tolerance, label);
}




function initObject() {
return {
Expand Down Expand Up @@ -494,9 +494,9 @@

equal(c1.__checkbox.checked,
object.booleanProperty);

console.log(c2.__checkbox.getAttribute('checked'));

equal(c2.__checkbox.getAttribute('checked') === 'checked',
object.anotherBooleanProperty);

Expand All @@ -518,7 +518,7 @@
dom.fakeEvent(c1.__checkbox, 'click');
equal(true, object.booleanProperty, 'changes back');

equal(true, c1.__checkbox.checked, 'checkbox valid');
equal(true, c1.__checkbox.checked, 'checkbox valid');



Expand Down Expand Up @@ -756,7 +756,7 @@
module("NumberControllerSlider");

test("Acknowledges original value", function() {

var object = initObject();

var min = 0, max = 50;
Expand Down Expand Up @@ -813,7 +813,7 @@


dom.fakeEvent(window, 'mouseup');

dom.fakeEvent(window, 'mousemove', {
x: o.left+w,
y: o.top
Expand Down Expand Up @@ -902,7 +902,7 @@
c4.onChange(function() {
c4_changed = true;
});

c5.onChange(function() {
c5_changed = true;
});
Expand Down Expand Up @@ -1006,7 +1006,7 @@
return ok(Math.abs(a - b) < tolerance, label);
}



module('GUI Appearance');

Expand Down Expand Up @@ -1052,7 +1052,7 @@
gui.destroy();
}, 0);
});

test('close/open button position', function() {

var gui = new GUI({closeOnTop:true});
Expand All @@ -1062,12 +1062,12 @@
ok($(gui.domElement).find('ul').prev().hasClass(GUI.CLASS_CLOSE_BUTTON) && $(gui.domElement).find('ul').prev().hasClass(GUI.CLASS_CLOSE_TOP), 'GUI has close/open button on top');
ok($(gui2.domElement).find('ul').next().hasClass(GUI.CLASS_CLOSE_BUTTON) && $(gui2.domElement).find('ul').next().hasClass(GUI.CLASS_CLOSE_BOTTOM), 'GUI has close/open button on bottom');
ok($(gui3.domElement).find('ul').next().hasClass(GUI.CLASS_CLOSE_BUTTON) && $(gui3.domElement).find('ul').next().hasClass(GUI.CLASS_CLOSE_BOTTOM), 'GUI has close/open button on bottom by default');

gui.destroy();
gui2.destroy();
gui3.destroy();

});
});

test('Folders', function() {

Expand Down Expand Up @@ -1187,6 +1187,20 @@

});

test('removeFolder', function() {

var gui = new GUI();

var f = gui.addFolder('Temporary folder');

ok($.contains(gui.domElement, f.domElement), "Now you see it");
gui.removeFolder(f);

ok(!$.contains(gui.domElement, f.domElement), "Now you don't.");

gui.destroy();

});

test('min, max & step', function() {

Expand Down Expand Up @@ -1417,11 +1431,11 @@
equal($(gui.__preset_select).children('option:selected')[0].value, gui.preset, "Dropdown display matches preset value");

}


});
</script>

</head>
<body>
<h1 id="qunit-header"></h1>
Expand All @@ -1433,4 +1447,4 @@ <h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</body>
</html>
</html>

0 comments on commit 59f685b

Please sign in to comment.