bbovenzi commented on code in PR #23456:
URL: https://github.com/apache/airflow/pull/23456#discussion_r865980917


##########
airflow/www/static/js/grid/components/Time.test.jsx:
##########
@@ -0,0 +1,83 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global describe, test, expect, document, Event */
+
+import React from 'react';
+import {
+  render, fireEvent, act,
+} from '@testing-library/react';
+import moment from 'moment-timezone';
+
+import { defaultFormatWithTZ, TimezoneEvent } from '../../datetime_utils';
+import Time from './Time';
+import { Wrapper } from '../utils/testUtils';
+
+describe('Test Time and TimezoneProvider', () => {
+  test('Displays a UTC time correctly', () => {
+    const now = new Date();
+    const { getByText } = render(
+      <Time dateTime={now} />,
+      { wrapper: Wrapper },
+    );
+
+    const utcTime = getByText(moment.utc(now).format(defaultFormatWithTZ));
+    expect(utcTime).toBeDefined();
+    expect(utcTime.title).toBeFalsy();
+  });
+
+  test('Displays moment default tz, includes UTC date in title', () => {
+    const now = new Date();
+    const tz = 'US/Samoa';
+    moment.tz.setDefault(tz);
+
+    const { getByText } = render(
+      <Time dateTime={now} />,
+      { wrapper: Wrapper },
+    );
+
+    const samoaTime = 
getByText(moment(now).tz(tz).format(defaultFormatWithTZ));
+    expect(samoaTime).toBeDefined();
+    
expect(samoaTime.title).toEqual(moment.utc(now).format(defaultFormatWithTZ));
+  });
+
+  test('Updates based on timezone change', async () => {
+    const now = new Date();
+    const { getByText, queryByText } = render(
+      <Time dateTime={now} />,
+      { wrapper: Wrapper },
+    );
+
+    const utcTime = queryByText(moment.utc(now).format(defaultFormatWithTZ));

Review Comment:
   No, as text is what the user sees so `queryByText` better approximates the 
actual UX.



-- 
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