Repository: apache/superset
File: superset-frontend/plugins/plugin-chart-ag-grid-table/test/AgGridTableChart.test.tsx (TypeScript)

Code before:
 * "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 '@testing-library/jest-dom';
import { render, waitFor } from '@superset-ui/core/spec';
import { QueryMode, TimeGranularity, SMART_DATE_ID } from '@superset-ui/core';
import { setupAGGridModules } from '@superset-ui/core/components/ThemedAgGridReact';
import AgGridTableChart from '../src/AgGridTableChart';
import transformProps from '../src/transformProps';
import { ProviderWrapper } from '../../plugin-chart-table/test/testHelpers';
import testData from '../../plugin-chart-table/test/testData';

beforeAll(() => {
  setupAGGridModules();
});

describe('transformProps', () => {
  it('should parse pageLength to pageSize', () => {
    expect(transformProps(testData.basic).pageSize).toBe(20);
    expect(
      transformProps({
        ...testData.basic,
        rawFormData: { ...testData.basic.rawFormData, page_length: '20' },
      }).pageSize,
    ).toBe(20);
    expect(
      transformProps({
        ...testData.basic,
        rawFormData: { ...testData.basic.rawFormData, page_length: '' },
      }).pageSize,
    ).toBe(0);
  });

  it('should not apply time grain formatting in Raw Records mode', () => {
    const rawRecordsProps = {
      ...testData.basic,
      rawFormData: {
        ...testData.basic.rawFormData,
        query_mode: QueryMode.Raw,
        time_grain_sqla: TimeGranularity.MONTH,
        table_timestamp_format: SMART_DATE_ID,
      },

Review comment (suggestion):
Maybe it’s worth checking the [guidelines ](https://superset.apache.org/developer_portal/testing/testing-guidelines/); they recommend avoiding describe blocks in favor of inline tests. If things get too large, we can split them into separate test files instead



Code after:
 * "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 '@testing-library/jest-dom';
import { render, screen, waitFor } from '@superset-ui/core/spec';
import { QueryMode, TimeGranularity, SMART_DATE_ID } from '@superset-ui/core';
import { setupAGGridModules } from '@superset-ui/core/components/ThemedAgGridReact';
import AgGridTableChart from '../src/AgGridTableChart';
import transformProps from '../src/transformProps';
import { ProviderWrapper } from '../../plugin-chart-table/test/testHelpers';
import testData from '../../plugin-chart-table/test/testData';

const mockSetDataMask = jest.fn();

beforeAll(() => {
  setupAGGridModules();
});

beforeEach(() => {
  jest.clearAllMocks();
});

test('transformProps parses pageLength to pageSize', () => {
  expect(transformProps(testData.basic).pageSize).toBe(20);
  expect(
    transformProps({
      ...testData.basic,
      rawFormData: { ...testData.basic.rawFormData, page_length: '20' },
    }).pageSize,
  ).toBe(20);
  expect(
    transformProps({
      ...testData.basic,
      rawFormData: { ...testData.basic.rawFormData, page_length: '' },
    }).pageSize,
  ).toBe(0);
});

test('transformProps does not apply time grain formatting in Raw Records mode', () => {
  const rawRecordsProps = {
    ...testData.basic,
    rawFormData: {