Browse Source

fix bug with dayCount and dateAlignment. tests

Adam Shaw 9 years ago
parent
commit
cffbe687d7
2 changed files with 24 additions and 14 deletions
  1. 2 8
      src/common/View.js
  2. 22 6
      tests/automated-better/view-dates/dateAlignment.js

+ 2 - 8
src/common/View.js

@@ -278,18 +278,12 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
 		var start = date.clone();
 		var end;
 
-		// if the view displays a single day or smaller
-		if (dayCount <= 1) {
-			if (this.isHiddenDay(start)) {
-				start = this.skipHiddenDays(start, direction);
-				start.startOf('day');
-			}
-		}
-
 		if (customAlignment) {
 			start.startOf(customAlignment);
 		}
+
 		start.startOf('day');
+		start = this.skipHiddenDays(start, direction);
 
 		end = start.clone();
 		do {

+ 22 - 6
tests/automated-better/view-dates/dateAlignment.js

@@ -5,14 +5,30 @@ SEE ALSO: next/prev
 describe('dateAlignment', function() {
 	pushOptions({
 		defaultView: 'agenda',
-		duration: { days: 3 },
-		dateAlignment: 'week'
+		dateAlignment: 'week',
+		defaultDate: '2017-06-15'
 	});
 
-	it('aligns with the week', function() {
-		initCalendar({
-			defaultDate: '2017-06-15'
+	describe('when 3 day duration', function() {
+		pushOptions({
+			duration: { days: 3 }
+		});
+
+		it('aligns with the week', function() {
+			initCalendar();
+			ViewDateUtils.expectVisibleRange('2017-06-11', '2017-06-14');
+		});
+	});
+
+	describe('when 5 day count', function() {
+		pushOptions({
+			dayCount: 5,
+			weekends: false
+		});
+
+		it('aligns with first visible day of the week', function() {
+			initCalendar();
+			ViewDateUtils.expectVisibleRange('2017-06-12', '2017-06-17');
 		});
-		ViewDateUtils.expectVisibleRange('2017-06-11', '2017-06-14');
 	});
 });