add test to check for detail pane titles

This commit is contained in:
David Kaltschmidt
2015-08-28 12:54:39 +02:00
parent b17d958b07
commit 2e50f6ae76
4 changed files with 55 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
describe('NodeDetails', () => {
let NodeDetails;
let nodes;
let nodeId;
let details;
const React = require('react');
const Immutable = require('immutable');
const TestUtils = require('react/lib/ReactTestUtils');
beforeEach(() => {
NodeDetails = require('../node-details.js');
nodes = Immutable.OrderedMap();
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.getDOMNode().textContent).toBe('Node 1');
});
});

View File

@@ -47,7 +47,7 @@ const NodeDetails = React.createClass({
render: function() {
const details = this.props.details;
const nodeExists = this.props.nodes[this.props.nodeId];
const nodeExists = this.props.nodes && this.props.nodes.has(this.props.nodeId);
if (!nodeExists) {
return this.renderNotAvailable();
@@ -58,7 +58,7 @@ const NodeDetails = React.createClass({
}
const style = {
'background-color': this.getNodeColorDark(details.label_major)
'backgroundColor': this.getNodeColorDark(details.label_major)
};
return (

View File

@@ -4,6 +4,7 @@ module.exports = function(config) {
'PhantomJS'
],
files: [
'./polyfill.js',
{
pattern: 'tests.webpack.js',
watched: false

21
client/test/polyfill.js Normal file
View File

@@ -0,0 +1,21 @@
/**
* Function.prototype.bind polyfill used by PhantomJS
*/
if (typeof Function.prototype.bind != 'function') {
Function.prototype.bind = function bind(obj) {
var args = Array.prototype.slice.call(arguments, 1),
self = this,
nop = function() {
},
bound = function() {
return self.apply(
this instanceof nop ? this : (obj || {}), args.concat(
Array.prototype.slice.call(arguments)
)
);
};
nop.prototype = this.prototype || {};
bound.prototype = new nop();
return bound;
};
}