/
HistoricElementView-test.js
54 lines (48 loc) · 1.65 KB
/
HistoricElementView-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* global jest, describe, beforeEach, it, expect */
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import ElementalAreaHistoryFactory from '../HistoricElementView';
describe('HistoricElementView', () => {
class FieldGroupStub extends React.Component {
getLegend() {
return 'nah';
}
getClassName() {
return 'ok';
}
render() {
return <div>Group</div>;
}
}
const datumSet = {
ElementType: 'Stub',
ElementTitle: 'Pretend Element',
ElementEditLink: 'http://localhost:8080/'
};
const HistoricElementView = ElementalAreaHistoryFactory(FieldGroupStub);
let history = null;
// Temporarily disable (with xdescribe):
xdescribe('render', () => {
beforeEach(() => {
history = ReactTestUtils.renderIntoDocument(
<HistoricElementView data={datumSet} />
);
});
it('The header should feature the Element type', () => {
const type = ReactTestUtils.findRenderedDOMComponentWithTag(history, 'small').textContent;
expect(type).toBeTruthy();
expect(type).toEqual('Stub');
});
it('should should list the Element\'s title', () => {
const title = ReactTestUtils.findRenderedDOMComponentWithClass(history, 'elemental-preview__detail').textContent;
expect(title).toBeTruthy();
expect(title).toMatch(/^Pretend Element\b/);
});
it('should should have a link in the header', () => {
const link = ReactTestUtils.findRenderedDOMComponentWithClass(history, 'elemental-preview__link');
expect(link).toBeTruthy();
expect(link.href).toBeTruthy();
expect(link.textContent).toEqual('View block');
});
});
});