calendar-weeks.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. module('Calendar Weeks', {
  2. setup: function(){
  3. this.input = $('<input type="text">')
  4. .appendTo('#qunit-fixture')
  5. .val('2013-01-14')
  6. .datepicker({
  7. format: 'yyyy-mm-dd',
  8. calendarWeeks: true
  9. })
  10. .focus(); // Activate for visibility checks
  11. this.dp = this.input.data('datepicker');
  12. this.picker = this.dp.picker;
  13. },
  14. teardown: function(){
  15. this.picker.remove();
  16. }
  17. });
  18. test('adds cw header column', function(){
  19. var target = this.picker.find('.datepicker-days thead tr:nth-child(3) th:first-child');
  20. ok(target.hasClass('cw'), 'First column heading is from cw column');
  21. });
  22. test('adds calendar week cells to each day row', function(){
  23. var target = this.picker.find('.datepicker-days tbody tr');
  24. expect(target.length);
  25. target.each(function(i){
  26. var t = $(this).children().first();
  27. ok(t.hasClass('cw'), "First column is cw column");
  28. });
  29. });
  30. test('displays correct calendar week', function(){
  31. var target = this.picker.find('.datepicker-days tbody tr');
  32. expect(target.length);
  33. target.each(function(i){
  34. var t = $(this).children().first();
  35. equal(t.text(), i+1, "Displays correct calendar weeks");
  36. });
  37. });
  38. test('it prepends column to switcher thead row', function(){
  39. var target = this.picker.find('.datepicker-days thead tr:nth-child(2)');
  40. equal(target.children().length, 3, 'first row has 3 columns');
  41. ok(!target.children().first().hasClass('cw'), 'cw column is not prepended');
  42. });