Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Fix failing unit tests #17166

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,12 @@ describe('angular', function() {
} else if (/Chrome\//.test(userAgent)) {
protocol = 'chrome-extension:';
} else if (/Safari\//.test(userAgent)) {
protocol = 'safari-extension:';
// On iOS, Safari versions <15 recognize `safari-extension:`, while versions >=15 only
// recognize `chrome-extension:`.
// (On macOS, Safari v15 recognizes both protocols, so it is fine to use either.)
var majorVersionMatch = /Version\/(\d+)/.exec(userAgent);
var majorVersion = majorVersionMatch ? parseInt(majorVersionMatch[1], 10) : 0;
protocol = (majorVersion < 15) ? 'safari-extension:' : 'chrome-extension:';
} else {
protocol = 'browserext:'; // Upcoming standard scheme.
}
Expand Down
48 changes: 24 additions & 24 deletions test/ng/directive/inputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1271,10 +1271,10 @@ describe('input', function() {
var inputElm = helper.compileInput('<input type="datetime-local" ng-model="breakMe"/>');

$rootScope.$apply(function() {
$rootScope.breakMe = new Date(2009, 0, 6, 16, 25, 0);
$rootScope.breakMe = new Date(2009, 0, 6, 16, 25, 1, 337);
});

expect(inputElm.val()).toBe('2009-01-06T16:25:00.000');
expect(inputElm.val()).toBe('2009-01-06T16:25:01.337');

//set to text for browsers with datetime-local validation.
inputElm[0].setAttribute('type', 'text');
Expand Down Expand Up @@ -1324,32 +1324,32 @@ describe('input', function() {
it('should use UTC if specified in the options', function() {
var inputElm = helper.compileInput('<input type="datetime-local" ng-model="value" ng-model-options="{timezone: \'UTC\'}" />');

helper.changeInputValueTo('2000-01-01T01:02');
expect(+$rootScope.value).toBe(Date.UTC(2000, 0, 1, 1, 2, 0));
helper.changeInputValueTo('2000-01-01T01:02:03.456');
expect(+$rootScope.value).toBe(Date.UTC(2000, 0, 1, 1, 2, 3, 456));

$rootScope.$apply(function() {
$rootScope.value = new Date(Date.UTC(2001, 0, 1, 1, 2, 0));
$rootScope.value = new Date(Date.UTC(2001, 0, 1, 1, 2, 3, 456));
});
expect(inputElm.val()).toBe('2001-01-01T01:02:00.000');
expect(inputElm.val()).toBe('2001-01-01T01:02:03.456');
});


it('should be possible to override the timezone', function() {
var inputElm = helper.compileInput('<input type="datetime-local" ng-model="value" ng-model-options="{timezone: \'UTC\'}" />');

helper.changeInputValueTo('2000-01-01T01:02');
expect(+$rootScope.value).toBe(Date.UTC(2000, 0, 1, 1, 2, 0));
helper.changeInputValueTo('2000-01-01T01:02:03.456');
expect(+$rootScope.value).toBe(Date.UTC(2000, 0, 1, 1, 2, 3, 456));

inputElm.controller('ngModel').$overrideModelOptions({timezone: '+0500'});
$rootScope.$apply(function() {
$rootScope.value = new Date(Date.UTC(2001, 0, 1, 1, 2, 0));
$rootScope.value = new Date(Date.UTC(2001, 0, 1, 1, 2, 3, 456));
});
expect(inputElm.val()).toBe('2001-01-01T06:02:00.000');
expect(inputElm.val()).toBe('2001-01-01T06:02:03.456');

inputElm.controller('ngModel').$overrideModelOptions({timezone: 'UTC'});

helper.changeInputValueTo('2000-01-01T01:02');
expect(+$rootScope.value).toBe(Date.UTC(2000, 0, 1, 1, 2, 0));
helper.changeInputValueTo('2000-01-01T01:02:03.456');
expect(+$rootScope.value).toBe(Date.UTC(2000, 0, 1, 1, 2, 3, 456));
});


Expand All @@ -1360,13 +1360,13 @@ describe('input', function() {
var inputElm = helper.compileInput(
'<input type="datetime-local" ng-model="value" ng-model-options="' + ngModelOptions + '" />');

helper.changeInputValueTo('2000-01-01T06:02');
expect(+$rootScope.value).toBe(Date.UTC(2000, 0, 1, 1, 2, 0));
helper.changeInputValueTo('2000-01-01T06:02:03.456');
expect(+$rootScope.value).toBe(Date.UTC(2000, 0, 1, 1, 2, 3, 456));

$rootScope.$apply(function() {
$rootScope.value = new Date(Date.UTC(2001, 0, 1, 1, 2, 0));
$rootScope.value = new Date(Date.UTC(2001, 0, 1, 1, 2, 3, 456));
});
expect(inputElm.val()).toBe('2001-01-01T06:02:00.000');
expect(inputElm.val()).toBe('2001-01-01T06:02:03.456');
}
);

Expand Down Expand Up @@ -1401,13 +1401,13 @@ describe('input', function() {
it('should allow to specify the seconds', function() {
var inputElm = helper.compileInput('<input type="datetime-local" ng-model="value"" />');

helper.changeInputValueTo('2000-01-01T01:02:03');
expect(+$rootScope.value).toBe(+new Date(2000, 0, 1, 1, 2, 3));
helper.changeInputValueTo('2000-01-01T01:02:03.456');
expect(+$rootScope.value).toBe(+new Date(2000, 0, 1, 1, 2, 3, 456));

$rootScope.$apply(function() {
$rootScope.value = new Date(2001, 0, 1, 1, 2, 3);
$rootScope.value = new Date(2001, 0, 1, 1, 2, 3, 456);
});
expect(inputElm.val()).toBe('2001-01-01T01:02:03.000');
expect(inputElm.val()).toBe('2001-01-01T01:02:03.456');
});


Expand All @@ -1425,13 +1425,13 @@ describe('input', function() {
it('should allow four or more digits in year', function() {
var inputElm = helper.compileInput('<input type="datetime-local" ng-model="value" />');

helper.changeInputValueTo('10123-01-01T01:02');
expect(+$rootScope.value).toBe(+new Date(10123, 0, 1, 1, 2, 0));
helper.changeInputValueTo('10123-01-01T01:02:03.456');
expect(+$rootScope.value).toBe(+new Date(10123, 0, 1, 1, 2, 3, 456));

$rootScope.$apply(function() {
$rootScope.value = new Date(20456, 1, 1, 1, 2, 0);
$rootScope.value = new Date(20456, 1, 1, 1, 2, 3, 456);
});
expect(inputElm.val()).toBe('20456-02-01T01:02:00.000');
expect(inputElm.val()).toBe('20456-02-01T01:02:03.456');
}
);
}
Expand Down