autoland-ui: Create AutolandController tests (Bug 1336249). r?imadueme draft
authorDavid Walsh <dwalsh@mozilla.com>
Fri, 03 Feb 2017 13:25:07 -0600
changeset 92 bd4356e6a37aa8a26c48d4655008f1a61acafddf
parent 91 621ff6903b0d0d49e60a6dfd335b6cfdb436b5c0
child 93 105579225ddbfceab31bc3f47ef957658b90adab
child 94 484a08abd57d886f06d7a0d67701d10664a71f3b
child 95 a3bdc1381c82a39a34cf94f8bcf3391d725d134c
child 96 0201daba6529119cadc8b1f05224df2add6b5f46
child 119 2515ca0fa03b45e0a53c4175b22ecf885678f97a
push id57
push userbmo:dwalsh@mozilla.com
push dateFri, 03 Feb 2017 21:43:45 +0000
reviewersimadueme
bugs1336249
autoland-ui: Create AutolandController tests (Bug 1336249). r?imadueme MozReview-Commit-ID: 68ZVKq4qzrf
autoland/ui/src/__tests__/AutolandController.js
autoland/ui/src/components/AutolandController.jsx
new file mode 100644
--- /dev/null
+++ b/autoland/ui/src/__tests__/AutolandController.js
@@ -0,0 +1,28 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+
+import AutolandController from '../components/AutolandController';
+
+describe('AutolandController', () => {
+
+  test('Renders "fetching data" message upon creation', () => {
+    const mount = shallow(
+      <AutolandController
+        params={{ series_id: 'example-02-can-be-landed', repo_id: 'test-repo' }} />
+    );
+
+    // The "fetching data" message should show right away
+    expect(mount.find('.fetching-data').length).toBe(1);
+  });
+
+  test('Error notification displays properly', () => {
+    const mount = shallow(
+      <AutolandController
+        params={{ series_id: 'example-02-can-be-landed', repo_id: 'test-repo' }} />
+    );
+
+    mount.instance().setState({ error: 'Error!' });
+    expect(mount.find('.warning').length).toBe(1);
+  });
+
+});
--- a/autoland/ui/src/components/AutolandController.jsx
+++ b/autoland/ui/src/components/AutolandController.jsx
@@ -77,17 +77,17 @@ class AutolandController extends React.C
     // Error!  One example could be a 404 for a bad ID
     if (this.state.error !== null) {
       return <span className="warning">{this.state.error}</span>;
     }
 
     // This is the default text for the element while we fetch data
     // during the initial widget creation
     if (data === null) {
-      return <span>Fetching data...</span>;
+      return <span className="fetching-data">Fetching data...</span>;
     }
 
     // For now, the only push that matters is the first provided back
     const push = data.pushes && data.pushes[0];
     const landing = data.landings && data.landings[0];
     const failures = {};
     let failureCount = 0;