Browse Source

test(ui): Add testablePose for use with react-pose (#12525)

Evan Purkhiser 6 years ago
parent
commit
278a2e4135
1 changed files with 23 additions and 0 deletions
  1. 23 0
      src/sentry/static/sentry/app/utils/testablePose.jsx

+ 23 - 0
src/sentry/static/sentry/app/utils/testablePose.jsx

@@ -0,0 +1,23 @@
+/* global process */
+
+/**
+ * Use with a react-pose animation to disable the animation in testing
+ * environments.
+ *
+ * This function simply sets delays and durations to 0.
+ */
+const testablePose = !process.env.IS_PERCY
+  ? a => a
+  : function(animation) {
+      Object.keys(animation).forEach(pose => {
+        animation[pose].delay = 0;
+        animation[pose].delayChildren = 0;
+        animation[pose].staggerChildren = 0;
+
+        animation[pose].transition = {duration: 0};
+      });
+
+      return animation;
+    };
+
+export default testablePose;