michael-s-molina commented on code in PR #27718:
URL: https://github.com/apache/superset/pull/27718#discussion_r1601467320


##########
superset-frontend/packages/superset-ui-core/src/time-comparison/getTimeOffset.ts:
##########
@@ -0,0 +1,121 @@
+/**
+ * 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.
+ */
+import { ensureIsArray } from '../utils';
+
+const DAY_IN_MS = 24 * 60 * 60 * 1000;
+export const parseDttmToDate = (dttm: string): Date => {

Review Comment:
   Isn't `parseDttmToDate` similar to 
[parse_human_datetime](https://github.com/apache/superset/blob/821c7d7f2c430c4a4294883a66128ba98fd949c5/superset/utils/date_parser.py#L57)?
 If yes, is there a way we can reuse that so we don't have 2 implementations to 
maintain?



##########
superset-frontend/packages/superset-ui-core/test/time-comparison/getTimeOffset.test.ts:
##########
@@ -0,0 +1,162 @@
+/**
+ * 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.
+ */
+import { getTimeOffset, parseDttmToDate } from '@superset-ui/core';
+
+describe('parseDttmToDate', () => {

Review Comment:
   Can you avoid `describe` and just use `test` to follow this [best 
practice](https://github.com/apache/superset/wiki/Testing-Guidelines-and-Best-Practices#avoid-nesting-when-youre-testing)?
 We're slowly refactoring the tests to move in that direction. 
   
   I noticed that this file name is `getTimeOffset.test.ts` but it's also 
testing `parseDttmToDate`. Can you rename the file to something more generic or 
breaking it into 2 test files?



##########
superset-frontend/packages/superset-ui-core/test/time-comparison/fetchTimeRange.test.ts:
##########
@@ -116,3 +117,54 @@ it('returns a formatted error message from response', 
async () => {
     error: 'Network error',
   });
 });
+
+it('fetchTimeRange with shift', async () => {

Review Comment:
   Same comment to use `test` instead of `it`.



-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to