Skip to content

Commit 557869d

Browse files
Merge pull request #9511 from elsamaryv/fix-test-failure-pr-9460
Replace getDay() with getDate() for accurate date value
2 parents 4b33d5c + c58d6b8 commit 557869d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

spec/javascripts/directives/checkchange_spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,19 @@ describe('checkchange initialization', function() {
3535

3636
$scope.$digest();
3737
var newDate = new Date();
38-
form.repo_path.$setViewValue(moment.utc([newDate.getFullYear(), newDate.getMonth(), newDate.getDay()]));
38+
form.repo_path.$setViewValue(moment.utc([newDate.getFullYear(), newDate.getMonth(), newDate.getDate()]));
3939
expect(form.repo_path.$pristine).toBe(false);
4040
expect(form.$pristine).toBe(false);
4141
});
4242

4343
it('should set the value and form to a pristine state when a date is unchanged', function() {
4444
var newDate = new Date();
45+
var mockDate = moment.utc([newDate.getFullYear(), newDate.getMonth(), newDate.getDate()]).toDate();
4546
$scope.repoModel = {repo_path : undefined};
46-
$scope.modelCopy = {repo_path : moment.utc([newDate.getFullYear(), newDate.getMonth(), newDate.getDay()]).toDate()};
47+
$scope.modelCopy = {repo_path : mockDate};
4748

4849
$scope.$digest();
49-
form.repo_path.$setViewValue(moment.utc([newDate.getFullYear(), newDate.getMonth(), newDate.getDay()]).toDate());
50+
form.repo_path.$setViewValue(mockDate);
5051
expect(form.repo_path.$pristine).toBe(true);
5152
expect(form.$pristine).toBe(true);
5253
});

0 commit comments

Comments
 (0)