This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch sc_74037
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 411c21f33b099922960b3660d9c2880c1f7fb5ba
Author: Beto Dealmeida <[email protected]>
AuthorDate: Mon Sep 25 14:20:04 2023 -0700

    Add tests
---
 .../formatters/finestTemporalGrain.test.ts         | 29 ++++++++++++++++++++++
 .../time-format/formatters/finestTemporalGrain.ts  |  3 +++
 2 files changed, 32 insertions(+)

diff --git 
a/superset-frontend/packages/superset-ui-core/src/time-format/formatters/finestTemporalGrain.test.ts
 
b/superset-frontend/packages/superset-ui-core/src/time-format/formatters/finestTemporalGrain.test.ts
new file mode 100644
index 0000000000..665e3d7a6e
--- /dev/null
+++ 
b/superset-frontend/packages/superset-ui-core/src/time-format/formatters/finestTemporalGrain.test.ts
@@ -0,0 +1,29 @@
+/*
+ * 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 finestTemporalGrain from './finestTemporalGrain';
+
+test('finestTemporalGrain', () => {
+  const formatter = finestTemporalGrain([
+    1041379200000, // 2023-01-01 00:00:00
+    1044057600000, // 2023-02-01 00:00:00
+  ]);
+  expect(formatter(1041379200000)).toBe('2003-01-01');
+  expect(formatter(1044057600000)).toBe('2003-02-01');
+});
diff --git 
a/superset-frontend/packages/superset-ui-core/src/time-format/formatters/finestTemporalGrain.ts
 
b/superset-frontend/packages/superset-ui-core/src/time-format/formatters/finestTemporalGrain.ts
index 1400a8eb5b..c03b7ec159 100644
--- 
a/superset-frontend/packages/superset-ui-core/src/time-format/formatters/finestTemporalGrain.ts
+++ 
b/superset-frontend/packages/superset-ui-core/src/time-format/formatters/finestTemporalGrain.ts
@@ -21,6 +21,9 @@ import { utcFormat, timeFormat } from 'd3-time-format';
 import { utcUtils, localTimeUtils } from '../utils/d3Time';
 import TimeFormatter from '../TimeFormatter';
 
+/*
+ * A formatter that examines all the values, and uses the finest temporal 
grain.
+ */
 export default function finestTemporalGrain(
   values: any[],
   useLocalTime = false,

Reply via email to