Renamed assertOneMap -> assertEmptyMap
Brian Vaughn committed
May 3, 2019 at 09:30 UTC
8585ee37dbfeb795ba4b7fc1f879af92fbb475dc
1 file changed
+25
-23
src/devtools/store.js
+25
-23
@@ -190,33 +190,35 @@ export default class Store extends EventEmitter {
190
this._profilingCache = new ProfilingCache(bridge, this);
191
}
192
193
+ // This is only used in tests to avoid memory leaks.
194
assertEmptyMaps() {
194
- // This is only used in tests to avoid memory leaks.
195
- const assertOneMap = (mapName, map) => {
196
- if (map.size !== 0) {
197
- throw new Error(
198
- `Expected ${mapName} to be empty, got ${
199
- map.size
200
- }: ${require('util').inspect(this, { depth: 20 })}`
201
- );
202
- }
203
- };
204
- assertOneMap('_idToElement', this._idToElement);
205
- assertOneMap('_ownersMap', this._ownersMap);
206
- assertOneMap(
207
- '_profilingOperationsByRootID',
208
- this._profilingOperationsByRootID
195
+ this.assertEmptyMap(this._idToElement, '_idToElement');
196
+ this.assertEmptyMap(this._ownersMap, '_ownersMap');
197
+ this.assertEmptyMap(
198
+ this._profilingOperationsByRootID,
199
+ '_profilingOperationsByRootID'
200
);
210
- assertOneMap(
211
- '_profilingScreenshotsByRootID',
212
- this._profilingScreenshotsByRootID
201
+ this.assertEmptyMap(
202
+ this._profilingScreenshotsByRootID,
203
+ '_profilingScreenshotsByRootID'
204
);
214
- assertOneMap(
215
- '_profilingSnapshotsByElementID',
216
- this._profilingSnapshotsByElementID
205
+ this.assertEmptyMap(
206
+ this._profilingSnapshotsByElementID,
207
+ '_profilingSnapshotsByElementID'
208
);
218
- assertOneMap('_rootIDToCapabilities', this._rootIDToCapabilities);
219
- assertOneMap('_rootIDToRendererID', this._rootIDToRendererID);
209
+ this.assertEmptyMap(this._rootIDToCapabilities, '_rootIDToCapabilities');
210
+ this.assertEmptyMap(this._rootIDToRendererID, '_rootIDToRendererID');
211
+ }
212
+
213
+ // This is only used in tests to avoid memory leaks.
214
+ assertEmptyMap(map: Map<any, any>, mapName: string) {
215
+ if (map.size !== 0) {
216
+ throw new Error(
217
+ `Expected ${mapName} to be empty, got ${
218
+ map.size
219
+ }: ${require('util').inspect(this, { depth: 20 })}`
220
+ );
221
+ }
222
}
223
224
get captureScreenshots(): boolean {