Browse Source

ProgressBar snapshot test

George Vrancianu 8 năm trước cách đây
mục cha
commit
65ca047838

+ 19 - 0
src/__tests__/ProgressBar.test.js

@@ -0,0 +1,19 @@
+import React from 'react';
+import { ProgressBar } from '../components/ProgressBar';
+import renderer from 'react-test-renderer';
+
+describe('Progress Bar', () => {
+  it('renders correctly', () => {
+    const tree = renderer.create(
+      <ProgressBar />
+    ).toJSON();
+    expect(tree).toMatchSnapshot();
+  });
+
+  it('renders progress correctly', () => {
+    const tree = renderer.create(
+      <ProgressBar progress={20} />
+    ).toJSON();
+    expect(tree).toMatchSnapshot();
+  });
+})

+ 39 - 0
src/__tests__/__snapshots__/ProgressBar.test.js.snap

@@ -0,0 +1,39 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Progress Bar renders correctly 1`] = `
+<div
+  className={undefined}
+>
+  <div
+    className={undefined}
+  >
+    <div
+      className="undefined "
+      style={
+        Object {
+          "width": "0%",
+        }
+      }
+    />
+  </div>
+</div>
+`;
+
+exports[`Progress Bar renders progress correctly 1`] = `
+<div
+  className={undefined}
+>
+  <div
+    className={undefined}
+  >
+    <div
+      className="undefined "
+      style={
+        Object {
+          "width": "20%",
+        }
+      }
+    />
+  </div>
+</div>
+`;

+ 1 - 1
src/components/ProgressBar/ProgressBar.js

@@ -20,7 +20,7 @@ import s from './ProgressBar.scss';
 import withStyles from 'isomorphic-style-loader/lib/withStyles';
 
 
-class ProgressBar extends Component {
+export class ProgressBar extends Component {
 
   static propTypes = {
     progress: PropTypes.number