| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- describe('weekNumbers', function() {
- var options
- var counts
- beforeEach(function() {
- affix('#cal')
- counts = {}
- options = {}
- })
- afterEach(function() {
- $('#cal').fullCalendar('destroy')
- })
- describe('when using month view', function() {
- beforeEach(function() {
- options.defaultView = 'month'
- options.fixedWeekCount = true // will make 6 rows
- })
- describe('with default weekNumbers', function() { // which is false!
- describe('and default weekNumbersWithinDays', function() {
- it('should not display week numbers at all', function() {
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to false', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = false
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to true', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = true
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- })
- describe('with weekNumbers to false', function() {
- beforeEach(function() {
- options.weekNumbers = false
- })
- describe('and default weekNumbersWithinDays', function() {
- it('should not display week numbers at all', function() {
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to false', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = false
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to true', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = true
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- })
- describe('with weekNumbers to true', function() {
- beforeEach(function() {
- options.weekNumbers = true
- })
- describe('and default weekNumbersWithinDays', function() {
- it('should display week numbers along the side only', function() {
- counts = getCounts()
- // TODO: Is it possible to remove class fc-week-number from
- // headers and fillers, bringing allWeekNumbers down to 6?
- expect(counts.colWeekNumbers).toEqual(6)
- expect(counts.cellWeekNumbers).toEqual(0)
- expect(counts.cornerWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to false', function() {
- it('should display week numbers along the side only', function() {
- options.weekNumbersWithinDays = false
- counts = getCounts()
- // TODO: Is it possible to remove class fc-week-number from
- // headers and fillers, bringing allWeekNumbers down to 6?
- expect(counts.colWeekNumbers).toEqual(6)
- expect(counts.cellWeekNumbers).toEqual(0)
- expect(counts.cornerWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to true', function() {
- it('should display week numbers in the day cells only', function() {
- options.weekNumbersWithinDays = true
- counts = getCounts()
- expect(counts.colWeekNumbers).toEqual(0)
- expect(counts.cellWeekNumbers).toEqual(6)
- expect(counts.cornerWeekNumbers).toEqual(0)
- })
- })
- })
- })
- describe('when using basicWeek view', function() {
- beforeEach(function() {
- options.defaultView = 'basicWeek'
- })
- describe('with default weekNumbers', function() {
- describe('and default weekNumbersWithinDays', function() {
- it('should not display week numbers at all', function() {
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to false', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = false
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to true', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = true
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- })
- describe('with weekNumbers to false', function() {
- beforeEach(function() {
- options.weekNumbers = false
- })
- describe('and default weekNumbersWithinDays', function() {
- it('should not display week numbers at all', function() {
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to false', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = false
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to true', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = true
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- })
- describe('with weekNumbers to true', function() {
- beforeEach(function() {
- options.weekNumbers = true
- })
- describe('and default weekNumbersWithinDays', function() {
- it('should display week numbers along the side only', function() {
- counts = getCounts()
- // TODO: Is it possible to remove class fc-week-number from
- // headers and fillers, bringing allWeekNumbers down to 1?
- expect(counts.colWeekNumbers).toEqual(1)
- expect(counts.cellWeekNumbers).toEqual(0)
- expect(counts.cornerWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to false', function() {
- it('should display week numbers along the side only', function() {
- options.weekNumbersWithinDays = false
- counts = getCounts()
- // TODO: Is it possible to remove class fc-week-number from
- // headers and fillers, bringing allWeekNumbers down to 1?
- expect(counts.colWeekNumbers).toEqual(1)
- expect(counts.cellWeekNumbers).toEqual(0)
- expect(counts.cornerWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to true', function() {
- it('should display week numbers in the day cells only', function() {
- options.weekNumbersWithinDays = true
- counts = getCounts()
- expect(counts.colWeekNumbers).toEqual(0)
- expect(counts.cellWeekNumbers).toEqual(1)
- expect(counts.cornerWeekNumbers).toEqual(0)
- })
- })
- })
- })
- describe('when using an agenda view', function() {
- beforeEach(function() {
- options.defaultView = 'agendaWeek'
- })
- describe('with default weekNumbers', function() {
- describe('and default weekNumbersWithinDays', function() {
- it('should not display week numbers at all', function() {
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to false', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = false
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to true', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = true
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- })
- describe('with weekNumbers to false', function() {
- beforeEach(function() {
- options.weekNumbers = false
- })
- describe('and default weekNumbersWithinDays', function() {
- it('should not display week numbers at all', function() {
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to false', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = false
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- describe('and weekNumbersWithinDays set to true', function() {
- it('should not display week numbers at all', function() {
- options.weekNumbersWithinDays = true
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(0)
- })
- })
- })
- describe('with weekNumbers to true', function() {
- beforeEach(function() {
- options.weekNumbers = true
- })
- describe('and default weekNumbersWithinDays', function() {
- it('should display week numbers in the top left corner only', function() {
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(1)
- expect(counts.colWeekNumbers).toEqual(0)
- expect(counts.cellWeekNumbers).toEqual(0)
- expect(counts.cornerWeekNumbers).toEqual(1)
- })
- })
- describe('and weekNumbersWithinDays set to false', function() {
- it('should display week numbers in the top left corner only', function() {
- options.weekNumbersWithinDays = false
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(1)
- expect(counts.colWeekNumbers).toEqual(0)
- expect(counts.cellWeekNumbers).toEqual(0)
- expect(counts.cornerWeekNumbers).toEqual(1)
- })
- })
- describe('and weekNumbersWithinDays set to true', function() {
- it('should display week numbers in the top left corner only', function() {
- options.weekNumbersWithinDays = true
- counts = getCounts()
- expect(counts.allWeekNumbers).toEqual(1)
- expect(counts.colWeekNumbers).toEqual(0)
- expect(counts.cellWeekNumbers).toEqual(0)
- expect(counts.cornerWeekNumbers).toEqual(1)
- })
- })
- })
- })
- function getCounts() {
- var t = {}
- $('#cal').fullCalendar(options)
- t.allWeekNumbers = $('.fc-week-number').length
- t.colWeekNumbers = $('.fc-content-skeleton thead td.fc-week-number').length
- t.cellWeekNumbers = $('.fc-content-skeleton thead .fc-day-top span.fc-week-number').length
- t.cornerWeekNumbers = $('.fc-axis.fc-widget-header.fc-week-number').length
- return t
- }
- })
|