yardz commented on a change in pull request #13753:
URL: https://github.com/apache/superset/pull/13753#discussion_r600862661



##########
File path: 
superset-frontend/src/explore/components/controls/FilterBoxItemControl/FilterBoxItemControl.test.tsx
##########
@@ -0,0 +1,78 @@
+/**
+ * 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 userEvent from '@testing-library/user-event';
+import FilterBoxItemControl from '.';
+
+const datasource = {
+  columns: [],
+  metrics: [],
+};
+
+let props = {

Review comment:
       > * For the tests where we have plain object props the spread operator 
`{...props}` is already guaranteeing immutability. In this case, we can define 
the default props as a `const` and override them in each test.
   
   This is very specific. It would only work for simpler objects (which is not 
the case most of the time)
   
   
   
   > * For more complex structures we could use Lodash `cloneDeep` and follow 
the same pattern.
   
   It is a good option when we do not have many functions. But I would like to 
avoid using more things than necessary in the tests ...
   
   > * If we want to use `beforeEach`, and assert that the default props have 
the correct type, we can do something like:
   
   Use factories! I loved this option, we didn't add external dependencies and 
we always have a new object. We can even remove the beforeEach in some cases. 
In the future we can add tests to check the immutability of the parameters. 
great idea!




-- 
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to