You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/04/01 14:02:57 UTC

[GitHub] [superset] michael-s-molina commented on a change in pull request #13875: test: CrossFilterScopingForm

michael-s-molina commented on a change in pull request #13875:
URL: https://github.com/apache/superset/pull/13875#discussion_r605681925



##########
File path: superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/CrossFilterScopingForm.test.tsx
##########
@@ -0,0 +1,77 @@
+/**
+ * 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 React from 'react';
+import { render, screen } from 'spec/helpers/testing-library';

Review comment:
       ```suggestion
   import { render } from 'spec/helpers/testing-library';
   import FilterScope from 'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope';
   ```

##########
File path: superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/CrossFilterScopingForm.test.tsx
##########
@@ -0,0 +1,77 @@
+/**
+ * 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 React from 'react';
+import { render, screen } from 'spec/helpers/testing-library';
+import CrossFilterScopingForm from '.';
+
+jest.mock(
+  'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope',
+  () => ({
+    __esModule: true,
+    default: (props: any) => (
+      <div
+        data-test="FilterScope"
+        data-scope={props.scope}
+        data-chart-id={props.chartId}
+        data-form-scope={props.formScope}
+        data-form-scoping={props.formScoping}
+      />
+    ),
+  }),
+);
+
+const createProps = () => {
+  const getFieldValue = jest.fn();
+  getFieldValue.mockImplementation(name => name);
+  return {
+    chartId: 123,
+    scope: 'Scope',
+    form: { getFieldValue },
+  };
+};
+
+test('Should send correct props', () => {
+  const props = createProps();
+  render(<CrossFilterScopingForm {...(props as any)} />);
+
+  expect(screen.getByTestId('FilterScope')).toHaveAttribute(
+    'data-form-scope',
+    'scope',
+  );
+  expect(screen.getByTestId('FilterScope')).toHaveAttribute(
+    'data-scope',
+    'Scope',
+  );
+  expect(screen.getByTestId('FilterScope')).toHaveAttribute(
+    'data-chart-id',
+    '123',
+  );
+  expect(screen.getByTestId('FilterScope')).toHaveAttribute(
+    'data-form-scoping',
+    'scoping',
+  );

Review comment:
       ```suggestion
     expect(FilterScope).toHaveBeenCalledWith(
       expect.objectContaining({
         chartId: 123,
         scope: 'Scope',
         formScope: 'scope',
         formScoping: 'scoping',
       }),
       {},
     );
   ```

##########
File path: superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/CrossFilterScopingForm.test.tsx
##########
@@ -0,0 +1,77 @@
+/**
+ * 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 React from 'react';
+import { render, screen } from 'spec/helpers/testing-library';
+import CrossFilterScopingForm from '.';
+
+jest.mock(
+  'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope',
+  () => ({
+    __esModule: true,
+    default: (props: any) => (
+      <div
+        data-test="FilterScope"
+        data-scope={props.scope}
+        data-chart-id={props.chartId}
+        data-form-scope={props.formScope}
+        data-form-scoping={props.formScoping}
+      />
+    ),
+  }),
+);

Review comment:
       ```suggestion
   jest.mock(
     'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope',
     () => jest.fn(() => null),
   );
   ```




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

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



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