Skip to content

Commit abfc24e

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
[test] Replace assertNotNullOrUndefined with assert.exists in unit tests
[email protected] Bug: None Change-Id: I2ac986c36fb8a8f417b72632a9b15fb5c566fef0 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6905382 Commit-Queue: Alex Rudenko <[email protected]> Auto-Submit: Simon Zünd <[email protected]> Reviewed-by: Alex Rudenko <[email protected]>
1 parent e9bba9b commit abfc24e

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

front_end/models/bindings/DebuggerLanguagePlugins.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('DebuggerLanguagePluginManager', () => {
108108

109109
const location = sinon.createStubInstance(SDK.DebuggerModel.Location);
110110
const result = await pluginManager.getFunctionInfo(script, location);
111-
Platform.assertNotNullOrUndefined(result);
111+
assert.exists(result);
112112
assert.deepEqual(result, {missingSymbolFiles: [MISSING_DEBUG_FILES]});
113113
});
114114

@@ -121,7 +121,7 @@ describe('DebuggerLanguagePluginManager', () => {
121121
const location = sinon.createStubInstance(SDK.DebuggerModel.Location);
122122

123123
const result = await pluginManager.getFunctionInfo(script, location);
124-
Platform.assertNotNullOrUndefined(result);
124+
assert.exists(result);
125125
assert.deepEqual(result, {frames: [{name: FUNCTION_NAME}]});
126126
});
127127

@@ -135,7 +135,7 @@ describe('DebuggerLanguagePluginManager', () => {
135135
const location = sinon.createStubInstance(SDK.DebuggerModel.Location);
136136

137137
const result = await pluginManager.getFunctionInfo(script, location);
138-
Platform.assertNotNullOrUndefined(result);
138+
assert.exists(result);
139139
assert.deepEqual(result, {frames: [{name: FUNCTION_NAME}], missingSymbolFiles: [MISSING_DEBUG_FILES]});
140140
});
141141
});

front_end/panels/application/BackgroundServiceView.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import * as Platform from '../../core/platform/platform.js';
5+
import type * as Platform from '../../core/platform/platform.js';
66
import * as SDK from '../../core/sdk/sdk.js';
77
import * as Protocol from '../../generated/protocol.js';
88
import {dispatchClickEvent} from '../../testing/DOMHelpers.js';
@@ -94,8 +94,8 @@ describeWithMockConnection('BackgroundServiceView', () => {
9494

9595
it('Triggers record on button click', () => {
9696
const recordButton = view.contentElement.querySelector('.empty-state devtools-button');
97-
Platform.assertNotNullOrUndefined(recordButton);
98-
assert.deepEqual(recordButton?.textContent, 'Start recording events');
97+
assert.exists(recordButton);
98+
assert.deepEqual(recordButton.textContent, 'Start recording events');
9999

100100
const recordingSpy = sinon.spy(view, 'toggleRecording');
101101
dispatchClickEvent(recordButton);

front_end/panels/common/AiCodeCompletionTeaser.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import * as Common from '../../core/common/common.js';
66
import * as Host from '../../core/host/host.js';
7-
import {assertNotNullOrUndefined} from '../../core/platform/platform.js';
87
import * as Root from '../../core/root/root.js';
98
import {renderElementIntoDOM} from '../../testing/DOMHelpers.js';
109
import {describeWithEnvironment, updateHostConfig} from '../../testing/EnvironmentHelpers.js';
@@ -43,7 +42,7 @@ describeWithEnvironment('AiCodeCompletionTeaser', () => {
4342
const showSnackbar = sinon.stub(Snackbars.Snackbar.Snackbar, 'show');
4443

4544
assert.isTrue(widget.isShowing());
46-
assertNotNullOrUndefined(view.input.onDismiss);
45+
assert.exists(view.input.onDismiss);
4746
view.input.onDismiss(new Event('click'));
4847
await widget.updateComplete;
4948

@@ -56,12 +55,12 @@ describeWithEnvironment('AiCodeCompletionTeaser', () => {
5655
const {view, widget} = await createTeaser();
5756
const showSnackbar = sinon.stub(Snackbars.Snackbar.Snackbar, 'show');
5857
const showViewStub = sinon.stub(UI.ViewManager.ViewManager.instance(), 'showView');
59-
assertNotNullOrUndefined(view.input.onDismiss);
58+
assert.exists(view.input.onDismiss);
6059
view.input.onDismiss(new Event('click'));
6160

6261
sinon.assert.calledOnce(showSnackbar);
6362
const snackbarOptions = showSnackbar.firstCall.args[0];
64-
assertNotNullOrUndefined(snackbarOptions.actionProperties);
63+
assert.exists(snackbarOptions.actionProperties);
6564
snackbarOptions.actionProperties.onClick();
6665

6766
assert.isTrue(showViewStub.calledOnceWith('chrome-ai'));

0 commit comments

Comments
 (0)