Skip to content

Commit

Permalink
add test for css class in disabled target
Browse files Browse the repository at this point in the history
  • Loading branch information
sporritt committed Sep 3, 2016
1 parent 375089c commit 7e1af0d
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion tests/jsPlumb-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2456,10 +2456,44 @@ var testSuite = function (renderMode, _jsPlumb) {
[1, 0.5, 0, 1]
]});
_jsPlumb.makeTarget(d17, { anchor: "LeftMiddle" }); // give it a non-default anchor, we will check this below.
_jsPlumb.setTargetEnabled(d17, false);
var originallyEnabled = _jsPlumb.setTargetEnabled("d17", false);
_jsPlumb.connect({source: e16, target: "d17"});
assertEndpointCount("d16", 1, _jsPlumb);
assertEndpointCount("d17", 0, _jsPlumb);


// tests for css class for disabled target
ok(_jsPlumb.hasClass(d17, "jtk-target-disabled"), "disabled class added");

ok(originallyEnabled, "setTargetEnabled returned the original enabled value of true when setting to false");
originallyEnabled = _jsPlumb.setTargetEnabled("d17", true);
ok(!originallyEnabled, "setTargetEnabled returned the previous enabled value of false when setting to true");

ok(!_jsPlumb.hasClass(d17, "jtk-target-disabled"), "disabled class removed");
});

// makeSource, then disable it. should not be able to make a connection to it.
test(": _jsPlumb.connect after makeTarget and setTargetEnabled(false) (DOM element as argument)", function () {
var d16 = _addDiv("d16"), d17 = _addDiv("d17");
var e16 = _jsPlumb.addEndpoint(d16, {isSource: true, isTarget: false}, {anchors: [
[0, 0.5, 0, -1],
[1, 0.5, 0, 1]
]});
_jsPlumb.makeTarget(d17, { anchor: "LeftMiddle" }); // give it a non-default anchor, we will check this below.
var originallyEnabled = _jsPlumb.setTargetEnabled(d17, false);
_jsPlumb.connect({source: e16, target: "d17"});
assertEndpointCount("d16", 1, _jsPlumb);
assertEndpointCount("d17", 0, _jsPlumb);


// tests for css class for disabled target
ok(_jsPlumb.hasClass(d17, "jtk-target-disabled"), "disabled class added");

ok(originallyEnabled, "setTargetEnabled returned the original enabled value of true when setting to false");
originallyEnabled = _jsPlumb.setTargetEnabled(d17, true);
ok(!originallyEnabled, "setTargetEnabled returned the previous enabled value of false when setting to true");

ok(!_jsPlumb.hasClass(d17, "jtk-target-disabled"), "disabled class removed");
});

// makeTarget, then disable it. should not be able to make a connection to it.
Expand Down

0 comments on commit 7e1af0d

Please sign in to comment.