From 4efdd72a24c4f058c123c63dc3604022b59b2c11 Mon Sep 17 00:00:00 2001 From: kozbial Date: Wed, 22 Sep 2021 17:14:41 -0700 Subject: [PATCH] Update captureWarnings usages to assertWarnings --- tests/mocha/registry_test.js | 6 ++---- tests/mocha/workspace_helpers.js | 14 +++++--------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tests/mocha/registry_test.js b/tests/mocha/registry_test.js index 7fa595575..cff50c38c 100644 --- a/tests/mocha/registry_test.js +++ b/tests/mocha/registry_test.js @@ -257,12 +257,10 @@ suite('Registry', function() { test('Incorrect Plugin Name', function() { this.options['plugins']['test'] = 'random'; var testClass; - var warnings = testHelpers.captureWarnings(() => { + assertWarnings(() => { testClass = Blockly.registry.getClassFromOptions('test', this.options); - }); + }, /Unable to find/); chai.assert.isNull(testClass); - chai.assert.equal(warnings.length, 1, - 'Expecting 1 warning about no name "random" found.'); }); }); }); diff --git a/tests/mocha/workspace_helpers.js b/tests/mocha/workspace_helpers.js index f656dd48d..9d4abea4e 100644 --- a/tests/mocha/workspace_helpers.js +++ b/tests/mocha/workspace_helpers.js @@ -6,7 +6,7 @@ goog.module('Blockly.test.workspaceHelpers'); -const {assertVariableValues, workspaceTeardown} = goog.require('Blockly.test.helpers'); +const {assertVariableValues, assertWarnings, workspaceTeardown} = goog.require('Blockly.test.helpers'); function testAWorkspace() { @@ -1294,11 +1294,9 @@ function testAWorkspace() { this.workspace.createVariable('name1', 'type1', 'id1'); this.workspace.deleteVariableById('id1'); var workspace = this.workspace; - var warnings = testHelpers.captureWarnings(function() { + assertWarnings(() => { workspace.deleteVariableById('id1'); - }); - chai.assert.equal(warnings.length, 1, - 'Expected 1 warning for second deleteVariableById call.'); + }, /Can't delete/); // Check the undoStack only recorded one delete event. var undoStack = this.workspace.undoStack_; @@ -1323,11 +1321,9 @@ function testAWorkspace() { createVarBlocksNoEvents(this.workspace, ['id1']); this.workspace.deleteVariableById('id1'); var workspace = this.workspace; - var warnings = testHelpers.captureWarnings(function() { + assertWarnings(() => { workspace.deleteVariableById('id1'); - }); - chai.assert.equal(warnings.length, 1, - 'Expected 1 warning for second deleteVariableById call.'); + }, /Can't delete/); // Check the undoStack only recorded one delete event. var undoStack = this.workspace.undoStack_;