1 | const React = require('react');
|
2 | const { expect } = require('chai');
|
3 | const { shallow } = require('enzyme');
|
4 | const { StringValue } = require('../');
|
5 |
|
6 | describe('<StringValue /> (rendering string)', () => {
|
7 | context('when the string is short', () => {
|
8 | const component = shallow(<StringValue type="String" value="testing" />);
|
9 |
|
10 | it('sets the base class', () => {
|
11 | expect(component.hasClass('element-value')).to.equal(true);
|
12 | });
|
13 |
|
14 | it('sets the type class', () => {
|
15 | expect(component.hasClass('element-value-is-string')).to.equal(true);
|
16 | });
|
17 |
|
18 | it('sets the title', () => {
|
19 | expect(component.props().title).to.equal('testing');
|
20 | });
|
21 |
|
22 | it('sets the value', () => {
|
23 | expect(component.text()).to.equal('\"testing\"');
|
24 | });
|
25 | });
|
26 |
|
27 | context('when the string is long', () => {
|
28 | const string = 'adfgdjfahgsdfadhfgadkfgkdfghdsjgfkdsahjfgdkasjhfgdasjkfhgdakjfhdgsfkajdshgfkjdashg' +
|
29 | 'akhjsdgfkasdjfhgsadfkjhgdasfkjagdsfkasdjhfgfskgdhfg';
|
30 | const component = shallow(<StringValue type="String" value={string} />);
|
31 |
|
32 | it('sets the base class', () => {
|
33 | expect(component.hasClass('element-value')).to.equal(true);
|
34 | });
|
35 |
|
36 | it('sets the type class', () => {
|
37 | expect(component.hasClass('element-value-is-string')).to.equal(true);
|
38 | });
|
39 |
|
40 | it('sets the title', () => {
|
41 | expect(component.props().title).to.equal(string);
|
42 | });
|
43 |
|
44 | it('sets the value', () => {
|
45 | const expected = '\"adfgdjfahgsdfadhfgadkfgkdfghdsjgfkdsahjfgdkasjhfgdasjkfhgdakjfhdgsfkaj...\"';
|
46 | expect(component.text()).to.equal(expected);
|
47 | });
|
48 | });
|
49 | });
|