pitrou commented on code in PR #40960:
URL: https://github.com/apache/arrow/pull/40960#discussion_r1551352350


##########
js/test/unit/vector/date-vector-tests.ts:
##########
@@ -15,34 +15,62 @@
 // specific language governing permissions and limitations
 // under the License.
 
-import { DateDay, DateMillisecond, RecordBatchReader, Table, vectorFromArray } 
from 'apache-arrow';
+import {
+    DateDay, DateMillisecond, TimestampMillisecond, TimestampMicrosecond, 
TimestampNanosecond, RecordBatchReader,
+    Table, vectorFromArray
+} from 'apache-arrow';
+
+describe(`TimestampVector`, () => {
+    test(`Dates are stored in TimestampMillisecond`, () => {
+        const date = new Date('2023-02-01T12:34:56Z');
+        const vec = vectorFromArray([date]);
+        expect(vec.type).toBeInstanceOf(TimestampMillisecond);
+        expect(vec.get(0)).toBe(date.getTime());
+    });
+
+    test(`Correctly get back TimestampMicrosecond from Date`, () => {
+        const date = new Date('2023-02-01T12:34:56Z');
+        const vec = vectorFromArray([date, 0.5], new TimestampMicrosecond);
+        expect(vec.type).toBeInstanceOf(TimestampMicrosecond);
+        expect(vec.get(0)).toBe(date.getTime());
+        expect(vec.get(1)).toBe(0.5);
+    });
+
+    test(`Correctly get back TimestampNanosecond from Date`, () => {
+        const date = new Date('2023-02-01T12:34:56Z');
+        const vec = vectorFromArray([date, 0.5], new TimestampNanosecond);
+        expect(vec.type).toBeInstanceOf(TimestampNanosecond);
+        expect(vec.get(0)).toBe(date.getTime());
+        expect(vec.get(1)).toBe(0.5);
+    });
+});

Review Comment:
   Why not also test TimestampSecond here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to