Skip to content

Commit

Permalink
Fixed an issue with role changes looking up defunct objects, thus not
Browse files Browse the repository at this point in the history
enabling NY raid functionality. Also added tests to check for this
behaviour in the future.
  • Loading branch information
Joakim Bjornstad committed Jul 4, 2013
1 parent d4de61b commit 7e737fe
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/javascript/tswcalc-selects.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ tswcalc.select.SelectHandler = function SelectHandler(slot) {

this.roleChange = function(event) {
var role = $(this).val();
if(ny_raid_items[slot.id_prefix][role] === undefined) {
if(tswcalc.data.ny_raid_items[slot.id_prefix][role] === undefined) {
tswcalc.slots[slot.id_prefix].el.btn.nyraid.attr('checked', false);
tswcalc.slots[slot.id_prefix].el.btn.nyraid.attr('disabled', 'disabled');
} else {
tswcalc.slots[slot.id_prefix].el.btn.nyraid.removeAttr('disabled');
}
if(slots[slot.id_prefix].el.btn.nyraid.is(':checked')) {
raidCheckboxes[slot.id_prefix].changeToRaidItem();
if(tswcalc.slots[slot.id_prefix].el.btn.nyraid.is(':checked')) {
tswcalc.checkbox[slot.id_prefix].changeToRaidItem();
} else {
raidCheckboxes[slot.id_prefix].changeToCustomItem();
tswcalc.checkbox[slot.id_prefix].changeToCustomItem();
}
tswcalc.summary.updatePrimaryStats();
};
Expand Down
6 changes: 6 additions & 0 deletions test/selects.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
<script src="../build/assets/javascripts/tswcalc-dusts.js"></script>
<script src="../src/javascript/data/tswcalc-data-signets.js"></script>
<script src="../src/javascript/data/tswcalc-data-slots.js"></script>
<script src="../src/javascript/data/tswcalc-data-nyraid.js"></script>
<script src="../src/javascript/data/tswcalc-data-glyphs.js"></script>
<script src="../src/javascript/data/tswcalc-data-costs.js"></script>
<script src="../src/javascript/data/tswcalc-data-gear.js"></script>
<script src="../src/javascript/tswcalc-selects.js"></script>
<script src="../src/javascript/tswcalc-summary.js"></script>
<script src="../src/javascript/tswcalc-checkbox.js"></script>
<script src="../src/javascript/tswcalc-slots.js"></script>
<script src="qunit/qunit-1.11.0.js"></script>
<script src="test-common.js"></script>
Expand Down
25 changes: 25 additions & 0 deletions test/selects.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,28 @@ test('should get signets for head', 1, function() {
equal(tswcalc.select['head'].getSignetsForHead('head').length, 16);
});

module('selects-integration-tests', {
setup: function() {
renderSlots();
tswcalc.slots.init();
initiateSelectHandlers();
initiateRaidCheckboxes();
initiateSummary();
}
});

test('should change role and have enabled checkbutton if NY raid item is found', 2, function() {
tswcalc.slots['head'].el.role.val('healer');
tswcalc.slots['head'].el.role.change();

equal($('#head-role').val(), "healer");
deepEqual($('#head-nyraid').attr('disabled'), undefined, 'ny raid checkbtn not disabled');
});

test('should change role and have disabled checkbutton if NY raid item is not found', 2, function() {
tswcalc.slots['wrist'].el.role.val('dps');
tswcalc.slots['wrist'].el.role.change();

equal($('#wrist-role').val(), "dps");
deepEqual($('#wrist-nyraid').attr('disabled'), 'disabled', 'ny raid checkbtn is disabled');
});

0 comments on commit 7e737fe

Please sign in to comment.