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

jumpinjackie / mapguide-react-layout / 15160437878

21 May 2025 11:00AM UTC coverage: 21.631% (-42.6%) from 64.24%
15160437878

Pull #1552

github

web-flow
Merge 8b7153d9e into 236e2ea07
Pull Request #1552: Feature/package updates 2505

839 of 1165 branches covered (72.02%)

11 of 151 new or added lines in 25 files covered. (7.28%)

1332 existing lines in 50 files now uncovered.

4794 of 22163 relevant lines covered (21.63%)

6.89 hits per line

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

80.43
/src/utils/type-guards.ts
1
import {
2
    InitError,
3
    IMapView,
4
    IModalDisplayOptions,
5
    IModalComponentDisplayOptions
6
} from "../api/common";
7
import { MapLayer, RuntimeMap } from "../api/contracts/runtime-map";
8
import { IInlineMenu, IFlyoutMenu, IComponentFlyoutItem } from "../components/toolbar";
9
import { IGenericSubjectMapLayer, ViewerAction } from '../actions/defs';
10
import { DeArrayifiedResult } from "../api/builders/deArrayify";
11

12
/**
13
 * Indicates if the given argument is an IModalDisplayOptions
14
 *
15
 * @export
16
 * @param {*} arg
17
 * @returns {arg is IModalDisplayOptions}
18
 */
19
export function isModalDisplayOptions(arg: any): arg is IModalDisplayOptions {
1✔
20
    return typeof(arg.url) != 'undefined';
×
UNCOV
21
}
×
22

23
/**
24
 * Indicates if the given argument is an IModalComponentDisplayOptions
25
 *
26
 * @export
27
 * @param {*} arg
28
 * @returns {arg is IModalComponentDisplayOptions}
29
 */
30
export function isModalComponentDisplayOptions(arg: any): arg is IModalComponentDisplayOptions {
1✔
31
    return typeof(arg.component) != 'undefined';
×
UNCOV
32
}
×
33

34
/**
35
 * Indicates if the given argument is an Error object
36
 *
37
 * @export
38
 * @param {*} err
39
 * @returns {err is Error}
40
 */
41
export function isError(err: any): err is Error {
1✔
42
    return err instanceof Error;
2✔
43
}
2✔
44

45
/**
46
 * Indicates if the given argument is an InitError object
47
 *
48
 * @export
49
 * @param {*} item
50
 * @returns {item is InitError}
51
 */
52
export function isInitError(item: any): item is InitError {
1✔
53
    return typeof (item.message) != 'undefined' && typeof (item.stack) != undefined;
1!
54
}
1✔
55

56
/**
57
 * Indicates if the given arguemnt has the shape of an IFlyoutMenu
58
 *
59
 * @export
60
 * @param {*} item
61
 * @returns {item is IFlyoutMenu}
62
 */
63
export function isMenuRef(item: any): item is IFlyoutMenu {
1✔
64
    return typeof (item.flyoutId) != 'undefined';
68✔
65
}
68✔
66

67
/**
68
 * Indicates if the given argument has the shape of an IComponentFlyoutItem
69
 *
70
 * @export
71
 * @param {*} item
72
 * @returns {item is IComponentFlyoutItem}
73
 */
74
export function isComponentFlyout(item: any): item is IComponentFlyoutItem {
1✔
75
    return typeof (item.componentName) != 'undefined';
68✔
76
}
68✔
77

78
/**
79
 * Indicates if the given argument has the shape of an IInlineMenu
80
 *
81
 * @export
82
 * @param {*} item
83
 * @returns {item is IInlineMenu}
84
 */
85
export function isMenu(item: any): item is IInlineMenu {
1✔
86
    return typeof (item.childItems) != 'undefined';
4✔
87
}
4✔
88

89
/**
90
 * Indicates if the given argument is a MapLayer object
91
 *
92
 * @export
93
 * @param {*} layer
94
 * @returns {layer is MapLayer}
95
 */
96
export function isLayer(layer: any): layer is MapLayer {
1✔
97
    return layer.LayerDefinition !== undefined;
×
UNCOV
98
}
×
99

100
/**
101
 * Indicates if the given argument has the shape of an IMapView
102
 *
103
 * @export
104
 * @param {*} view
105
 * @returns {view is IMapView}
106
 */
107
export function isMapView(view: any): view is IMapView {
1✔
108
    return typeof (view.x) == 'number'
2✔
109
        && typeof (view.y) == 'number'
2✔
110
        && typeof (view.scale) == 'number';
2✔
111
}
2✔
112

113
/**
114
 * Indicates if the given argument is a coordinate pair
115
 *
116
 * @export
117
 * @param {*} coord
118
 * @returns {coord is [number, number]}
119
 */
120
export function isCoordinate(coord: any): coord is [number, number] {
1✔
121
    return coord instanceof Array
1✔
122
        && coord.length == 2
1✔
123
        && typeof (coord[0]) == 'number'
1✔
124
        && typeof (coord[1]) == 'number';
1✔
125
}
1✔
126

127
/**
128
 * Indicates if the given argument has the shape of a ViewerAction
129
 *
130
 * @export
131
 * @param {*} action
132
 * @returns {action is ViewerAction}
133
 */
134
export function isAction(action: any): action is ViewerAction {
1✔
135
    return typeof (action.type) != 'undefined'
×
UNCOV
136
        && typeof (action.payload) != 'undefined';
×
UNCOV
137
}
×
138

139
/**
140
 * Indicates if the given argument is a RuntimeMap
141
 * 
142
 * @param arg 
143
 * @returns 
144
 * @since 0.14
145
 */
146
export function isRuntimeMap(arg: DeArrayifiedResult | RuntimeMap | IGenericSubjectMapLayer): arg is RuntimeMap {
1✔
147
    return (arg as any).Extents != null
4✔
148
        && (arg as any).BackgroundColor != null
4✔
149
        && (arg as any).CoordinateSystem != null
4✔
150
        && (arg as any).MapDefinition != null
4✔
151
        && (arg as any).DisplayDpi != null;
4✔
152
}
4✔
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