Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Sign In

uber / deck.gl / 13127

29 Aug 2019 - 17:33 coverage increased (+2.5%) to 83.552%
13127

Pull #3507

travis-ci-com

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
update the component-wrapping-rfc.md
Pull Request #3507: update the component-wrapping-rfc.md

3393 of 4570 branches covered (74.25%)

Branch coverage included in aggregate %.

7066 of 7948 relevant lines covered (88.9%)

3403.06 hits per line

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

76.47
/modules/json/src/json-converter/json-converter.js
1
// Converts JSON to props ("hydrating" classes, resolving enums and functions etc).
2
// TODO - Currently converts in place, might be clearer to convert to separate structure
3

4
import {shallowEqualObjects} from '../utils/shallow-equal-objects.js';
5
import parseJSON from '../parsers/parse-json';
6
import {convertTopLevelJSON} from '../parsers/convert-json';
7

8
export default class JSONConverter {
9
  constructor(props) {
10
    this.configuration = {};
1×
11
    this.onJSONChange = () => {};
8×
12
    // this._onViewStateChange = this._onViewStateChange.bind(this);
13
    this.setProps(props);
1×
14
  }
15

16
  finalize() {}
17

18
  setProps(props) {
19
    // HANDLE CONFIGURATION PROPS
20
    if ('configuration' in props) {
Branches [[0, 1]] missed. 2×
21
      this.configuration = props.configuration;
1×
22
    }
23

24
    if ('onJSONChange' in props) {
Branches [[1, 0]] missed. 2×
25
      this.onJSONChange = props.onJSONChange;
1×
26
    }
27
  }
28

29
  convertJsonToDeckProps(json) {
30
    // Use shallow equality to Ensure we only convert once
31
    if (!json || json === this.json) {
Branches [[2, 0]] missed. 2×
32
      return this.deckProps;
3×
33
    }
34
    this.json = json;
3×
35

36
    // Accept JSON strings by parsing them
37
    const parsedJSON = parseJSON(json);
3×
38

39
    // Convert the JSON
40
    const jsonProps = convertTopLevelJSON(parsedJSON, this.configuration);
3×
41

42
    // Handle `json.initialViewState`
43
    // If we receive new JSON we need to decide if we should update current view state
44
    // Current heuristic is to compare with last `initialViewState` and only update if changed
45
    if ('initialViewState' in jsonProps) {
Branches [[4, 1]] missed. 3×
46
      const updateViewState =
47
        !this.initialViewState ||
Branches [[5, 1]] missed. 3×
48
        !shallowEqualObjects(jsonProps.initialViewState, this.initialViewState);
49

UNCOV
50
      if (updateViewState) {
Branches [[6, 1]] missed. !
51
        jsonProps.viewState = jsonProps.initialViewState;
2×
UNCOV
52
        this.initialViewState = jsonProps.initialViewState;
!
53
      }
54

55
      delete jsonProps.initialViewState;
2×
56
    }
57

58
    this.deckProps = jsonProps;
2×
59
    return jsonProps;
2×
60
  }
61
}
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
BLOG · TWITTER · Legal & Privacy · Supported CI Services · What's a CI service? · Automated Testing

© 2019 Coveralls, LLC