Files
weave-scope/client/app/scripts/components/__tests__/node-details-test.js
David Kaltschmidt 6b445466ef Move JS to ES2015
Refactored mixins into utils

ES2015 module exports

ES2015-style imports

WIP Fixing tests

Fixes tests after es2015 code migrations.

We we're require()ing an ES2015 module[1]. Have to make sure you account
for the .default in this case.

[1] We had to use ES5 `require` in Jest:
(https://github.com/babel/babel-jest/issues/16)
2015-12-01 14:35:22 +01:00

40 lines
1.3 KiB
JavaScript

import React from 'react';
import Immutable from 'immutable';
import TestUtils from 'react/lib/ReactTestUtils';
jest.dontMock('../../dispatcher/app-dispatcher');
jest.dontMock('../node-details.js');
jest.dontMock('../../utils/color-utils');
jest.dontMock('../../utils/title-utils');
// need ES5 require to keep automocking off
const NodeDetails = require('../node-details.js').default;
describe('NodeDetails', () => {
let nodes;
let nodeId;
let details;
const makeMap = Immutable.OrderedMap;
beforeEach(() => {
nodes = makeMap();
nodeId = 'n1';
});
it('shows n/a when node was not found', () => {
const c = TestUtils.renderIntoDocument(<NodeDetails nodes={nodes} nodeId={nodeId} />);
const notFound = TestUtils.findRenderedDOMComponentWithClass(c, 'node-details-header-notavailable');
expect(notFound).toBeDefined();
});
it('show label of node with title', () => {
nodes = nodes.set(nodeId, Immutable.fromJS({id: nodeId}));
details = {label_major: 'Node 1', tables: []};
const c = TestUtils.renderIntoDocument(<NodeDetails nodes={nodes}
nodeId={nodeId} details={details} />);
const title = TestUtils.findRenderedDOMComponentWithClass(c, 'node-details-header-label');
expect(title.textContent).toBe('Node 1');
});
});