Kaynağa Gözat

tests for dynamic theme change; compound option change

Adam Shaw 9 yıl önce
ebeveyn
işleme
de123025a5
2 değiştirilmiş dosya ile 56 ekleme ve 0 silme
  1. 1 0
      build/karma.conf.js
  2. 55 0
      tests/automated/theme.js

+ 1 - 0
build/karma.conf.js

@@ -23,6 +23,7 @@ module.exports = function(config) {
 			'../lib/moment/moment.js',
 			'../lib/jquery/dist/jquery.js',
 			'../lib/jquery-ui/jquery-ui.js',
+			'../lib/jquery-ui/themes/cupertino/jquery-ui.min.css',
 
 			'../lib/jquery-simulate/jquery.simulate.js',
 			'../lib/jquery-mockjax/dist/jquery.mockjax.js',

+ 55 - 0
tests/automated/theme.js

@@ -0,0 +1,55 @@
+describe('theme', function() {
+
+	it('can be changed dynamically', function() {
+		affix('#cal');
+		$('#cal').fullCalendar({
+			defaultView: 'agendaWeek'
+		});
+
+		expect($('.fc')).toHaveClass('fc-unthemed');
+		expect($('.fc')).not.toHaveClass('ui-widget');
+		expect($('.fc-toolbar button .fc-icon').length).toBeGreaterThan(0);
+		expect($('.fc-toolbar button .ui-icon').length).toBe(0);
+		expect($('.ui-widget-header').length).toBe(0);
+
+		$('.fc-scroller').scrollTop(99999); // scroll all the way down
+		var scrollTop = $('.fc-scroller').scrollTop();
+
+		// change option!
+		$('#cal').fullCalendar('option', 'theme', true);
+
+		expect($('.fc')).toHaveClass('ui-widget');
+		expect($('.fc')).not.toHaveClass('fc-unthemed');
+		expect($('.fc-toolbar button .fc-icon').length).toBe(0);
+		expect($('.fc-toolbar button .ui-icon').length).toBeGreaterThan(0);
+		expect($('.ui-widget-header').length).toBeGreaterThan(0);
+
+		// similar scroll state after the change
+		expect(Math.abs(scrollTop - $('.fc-scroller').scrollTop())).toBeLessThan(5);
+	});
+
+
+	// this tests the options setter with a single hash argument.
+	// TODO: not best place for this.
+	it('can be change with other options', function() {
+		affix('#cal');
+		$('#cal').fullCalendar({
+			defaultView: 'agendaWeek'
+		});
+
+		expect($('.fc')).toHaveClass('fc-unthemed');
+		expect($('.fc')).not.toHaveClass('ui-widget');
+		expect($('.fc-nonbusiness').length).toBe(0);
+
+		// change option!
+		$('#cal').fullCalendar('option', {
+			theme: true,
+			businessHours: true
+		});
+
+		expect($('.fc')).toHaveClass('ui-widget');
+		expect($('.fc')).not.toHaveClass('fc-unthemed');
+		expect($('.fc-nonbusiness').length).toBeGreaterThan(0);
+	});
+
+});