mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-03 05:39:45 +00:00
Tests: Record dates by instant in the drop-in snapshot
* DropInSnapshot.j: - Describe a CPDate by its UTC instant instead of its class name. - Record the string value of a control holding a date by the date's instant, since the browser formats it in the local time zone. * DropInArchives.json: Update the CPDatePicker entry to the instant it archives. * DropInArchiveTest.j: State that the test must pass in every time zone, and how to check it in UTC.
This commit is contained in:
1 parent
aa4652921a
commit
a4b3d76da1
3 files changed
+26
-2
No files matched your search
@@ -125,6 +125,14 @@ var fs = require("fs"),
|
||||
|
||||
/*
|
||||
An archive written by main must restore the view it was written from.
|
||||
|
||||
The descriptions compared must be the same on every machine. A date, and the
|
||||
string value of a control that holds one, are recorded by the date's instant in
|
||||
UTC, because their text is in the local time zone (DropInSnapshot.j). GitHub's
|
||||
continuous integration runs this test in UTC, so run it in UTC as well as in the
|
||||
local time zone before committing a change:
|
||||
|
||||
TZ=UTC npx jake test
|
||||
*/
|
||||
- (void)testExistingArchivesRestoreTheOriginalView
|
||||
{
|
||||
|
||||
@@ -165,6 +165,13 @@ function DropInDescribeValue(aValue)
|
||||
|
||||
if (aValue.isa)
|
||||
{
|
||||
/*
|
||||
A date is recorded by its instant in UTC. Its description is in the time zone
|
||||
of the machine that runs the test, so it differs between machines.
|
||||
*/
|
||||
if ([aValue isKindOfClass:[CPDate class]])
|
||||
return "CPDate:" + (isNaN(aValue.getTime()) ? "invalid" : aValue.toISOString());
|
||||
|
||||
if ([aValue isKindOfClass:[CPColor class]])
|
||||
return "CPColor:" + [aValue cssString];
|
||||
|
||||
@@ -286,6 +293,15 @@ function DropInViewTreeState(aView)
|
||||
|
||||
var value = [aView performSelector:selector];
|
||||
|
||||
/*
|
||||
A control that holds a date gives its string value in the time zone of the
|
||||
machine that runs the test, because the browser formats it, not Cappuccino. It
|
||||
is recorded by the date's instant instead, so that every machine records the
|
||||
same snapshot.
|
||||
*/
|
||||
if (aGetter === @"stringValue" && [aView respondsToSelector:@selector(objectValue)] && [[aView objectValue] isKindOfClass:[CPDate class]])
|
||||
value = [aView objectValue];
|
||||
|
||||
state[aGetter] = DropInDescribeValue(DropInBooleanGetters.indexOf(aGetter) !== -1 ? !!value : value);
|
||||
});
|
||||
|
||||
|
||||
@@ -755,8 +755,8 @@
|
||||
"lineBreakMode": "2",
|
||||
"verticalAlignment": "1",
|
||||
"doubleValue": "0",
|
||||
"objectValue": "CPDate",
|
||||
"stringValue": "Sat Oct 31 2026 06:00:00 GMT-0600 (Mountain Daylight Time)",
|
||||
"objectValue": "CPDate:2026-10-31T12:00:00.000Z",
|
||||
"stringValue": "CPDate:2026-10-31T12:00:00.000Z",
|
||||
"tag": "-1"
|
||||
},
|
||||
"subviews": [
|
||||
|
||||
Reference in new issue
Block a user