Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

ensured the scheduler input checked attribute is being set, not just setting the active css class #1074

Merged
merged 4 commits into from
Feb 12, 2015
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
item.find('label').removeClass('active');
temp = recur.BYDAY.split(',');
for (i = 0, l = temp.length; i < l; i++) {
item.find('input[data-value="' + temp[i] + '"]').parent().addClass('active');
item.find('input[data-value="' + temp[i] + '"]').attr('checked',true).parent().addClass('active');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like your unit test is checking for the checked attr to be present and true, is this on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was intending to test getValue which in turn tests this indirectly. I will create a separate unit test to explicitly test the checked attribute.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be .prop('checked', true) not attr('checked', true). http://api.jquery.com/prop/

the most important concept to remember about the checked attribute is that it does not correspond to the checked property. The attribute actually corresponds to the defaultChecked property and should be used only to set the initial value of the checkbox. The checked attribute value does not change with the state of the checkbox, while the checked property does.

}
}

Expand Down
20 changes: 20 additions & 0 deletions test/scheduler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
define(function(require){
var $ = require('jquery');
var html = require('text!test/markup/scheduler-markup.html');
var templateHtml = html;

/* FOR DEV TESTING */
// html = require('text!index.html!strip');
html = $('<div>'+html+'</div>').find('#MyScheduler');
Expand Down Expand Up @@ -212,6 +214,24 @@ define(function(require){
// }
});

test('should set/get recurrence pattern properly', function() {
var schedule = {
startDateTime: '2014-03-31T03:23+02:00',
timeZone: {
offset: '+02:00'
},
recurrencePattern: 'FREQ=WEEKLY;BYDAY=WE;INTERVAL=1;'
};

// note: currently, the scheduler doesn't reset it's markup/state
// when setValue is called. so ensure we're starting with initial template markup
// that hasn't been altered by another unit test
var $scheduler = $('<div>'+templateHtml+'</div>').find('#MyScheduler').scheduler();
$scheduler.scheduler('value', schedule);

equal($scheduler.scheduler('value').recurrencePattern, schedule.recurrencePattern, 'schedule set correctly');
});

// TODO: need more end date test or dry out code where start and end use same methods

test('should initialize with end date provided', function() {
Expand Down