node-details-test.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React from 'react';
  2. import Immutable from 'immutable';
  3. import TestUtils from 'react-dom/test-utils';
  4. import { Provider } from 'react-redux';
  5. import configureStore from '../../stores/configureStore';
  6. // need ES5 require to keep automocking off
  7. const NodeDetails = require('../node-details.js').default.WrappedComponent;
  8. describe('NodeDetails', () => {
  9. let nodes;
  10. let nodeId;
  11. let details;
  12. const makeMap = Immutable.OrderedMap;
  13. beforeEach(() => {
  14. nodes = makeMap();
  15. nodeId = 'n1';
  16. });
  17. it('shows n/a when node was not found', () => {
  18. const c = TestUtils.renderIntoDocument((
  19. <Provider store={configureStore()}>
  20. <NodeDetails notFound />
  21. </Provider>
  22. ));
  23. const notFound = TestUtils.findRenderedDOMComponentWithClass(
  24. c,
  25. 'node-details-header-notavailable'
  26. );
  27. expect(notFound).toBeDefined();
  28. });
  29. it('show label of node with title', () => {
  30. nodes = nodes.set(nodeId, Immutable.fromJS({id: nodeId}));
  31. details = {label: 'Node 1'};
  32. const c = TestUtils.renderIntoDocument((
  33. <Provider store={configureStore()}>
  34. <NodeDetails
  35. nodes={nodes}
  36. topologyId="containers"
  37. nodeId={nodeId}
  38. details={details}
  39. />
  40. </Provider>
  41. ));
  42. const title = TestUtils.findRenderedDOMComponentWithClass(c, 'node-details-header-label');
  43. expect(title.title).toBe('Node 1');
  44. });
  45. });