zhaoyongjie commented on code in PR #22015:
URL: https://github.com/apache/superset/pull/22015#discussion_r1012577085


##########
superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts:
##########
@@ -16,48 +16,41 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-import { FeatureFlag, isFeatureEnabled } from '@superset-ui/core';
-
-const originalFeatureFlags = window.featureFlags;
-// eslint-disable-next-line no-console
-const originalConsoleError = console.error;
-const reset = () => {
-  window.featureFlags = originalFeatureFlags;
-  // eslint-disable-next-line no-console
-  console.error = originalConsoleError;
-};
+import mockConsole from 'jest-mock-console';
+import { isFeatureEnabled, FeatureFlag } from '@superset-ui/core';
 
 it('returns false and raises console error if feature flags have not been 
initialized', () => {
-  // eslint-disable-next-line no-console
-  console.error = jest.fn();
-  delete (window as any).featureFlags;
-  
expect(isFeatureEnabled(FeatureFlag.ALLOW_DASHBOARD_DOMAIN_SHARDING)).toEqual(
-    false,
-  );
-
-  // eslint-disable-next-line no-console
-  expect(console.error).toHaveBeenNthCalledWith(
-    1,
-    'Failed to query feature flag ALLOW_DASHBOARD_DOMAIN_SHARDING (see error 
below)',
+  mockConsole();
+  Object.defineProperty(window, 'featureFlags', {
+    value: undefined,
+  });
+
+  expect(
+    isFeatureEnabled(FeatureFlag.ALLOW_DASHBOARD_DOMAIN_SHARDING),
+  ).toBeFalsy();

Review Comment:
   Good point. I mistakenly thought that `toBeFalsy()` is a shortcut for 
`toEqual(false)`. will update



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

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