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

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

05 Feb 2021 11:19PM UTC coverage: 2.313% (-80.9%) from 83.209%
#3046

push

web-flow
Merge pull request #328 from mac-s-g/bump-minor

quotesOnKeys bugfix

0 of 412 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 1 file covered. (0.0%)

593 existing lines in 29 files now uncovered.

25 of 669 relevant lines covered (3.74%)

0.04 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) {
UNCOV
13
        super(props);
×
UNCOV
14
        this.state = {
×
15
            collapsed: AttributeStore.get(
16
                props.rjvId,
17
                props.namespace,
18
                'collapsed',
19
                true
20
            )
21
        };
22
    }
23

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

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

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

UNCOV
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