• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mac-s-g / react-json-view / #2963

18 Mar 2024 12:10PM UTC coverage: 15.895% (-67.3%) from 83.209%
#2963

push

loredanacirstea
1.21.6

57 of 368 branches covered (15.49%)

Branch coverage included in aggregate %.

101 of 626 relevant lines covered (16.13%)

0.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/js/components/DataTypes/String.js
1
import React from 'react';
2
import DataTypeLabel from './DataTypeLabel';
3
import { toType } from './../../helpers/util';
4

5
//theme
6
import Theme from './../../themes/getStyle';
7

8
//attribute store for storing collapsed state
9
import AttributeStore from './../../stores/ObjectAttributes';
10

11
export default class extends React.PureComponent {
12
    constructor(props) {
13
        super(props);
×
14
        this.state = {
×
15
            collapsed: AttributeStore.get(
16
                props.rjvId,
17
                props.namespace,
18
                'collapsed',
19
                true
20
            )
21
        };
22
    }
23

24
    toggleCollapsed = () => {
×
25
        this.setState(
×
26
            {
27
                collapsed: !this.state.collapsed
28
            },
29
            () => {
30
                AttributeStore.set(
×
31
                    this.props.rjvId,
32
                    this.props.namespace,
33
                    'collapsed',
34
                    this.state.collapsed
35
                );
36
            }
37
        );
38
    };
39

40
    render() {
41
        const type_name = 'string';
×
42
        const { collapsed } = this.state;
×
43
        const { props } = this;
×
44
        const { collapseStringsAfterLength, theme } = props;
×
45
        let { value } = props;
×
46
        let collapsible = toType(collapseStringsAfterLength) === 'integer';
×
47
        let style = { style: { cursor: 'default' } };
×
48

49
        if (collapsible && value.length > collapseStringsAfterLength) {
×
50
            style.style.cursor = 'pointer';
×
51
            if (this.state.collapsed) {
×
52
                value = (
×
53
                    <span>
54
                        {value.substring(0, collapseStringsAfterLength)}
55
                        <span {...Theme(theme, 'ellipsis')}> ...</span>
56
                    </span>
57
                );
58
            }
59
        }
60

61
        return (
×
62
            <div {...Theme(theme, 'string')}>
63
                <DataTypeLabel type_name={type_name} {...props} />
64
                <span
65
                    class="string-value"
66
                    {...style}
67
                    onClick={this.toggleCollapsed}
68
                >
69
                    "{value}"
70
                </span>
71
            </div>
72
        );
73
    }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc