Files
blockly/tests/mocha/dialog_test.js
Beka Westberg 278006b5f8 feat: allow the dialog methods to take in extra parameters (#8084)
* feat: allow prompt to take in additional params

* feat: allow confirm tot ake in extra args

* feat: allow alert dialog to take in extra parameters

* chore: add tests for dialog methods
2024-05-08 10:10:09 -07:00

59 lines
1.4 KiB
JavaScript

/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
suite.only('Dialog', function () {
teardown(function () {
sinon.restore();
});
suite('Prompt', function () {
test('setPrompt can take in a function with additional parameters', function () {
const spy = sinon.spy();
Blockly.dialog.setPrompt(spy);
const callback = () => {};
Blockly.dialog.prompt(
'message',
'defaultVal',
callback,
'extra parameter',
);
chai.assert.isTrue(
spy.calledWith('message', 'defaultVal', callback, 'extra parameter'),
);
});
});
suite('Confirm', function () {
test('setConfirm can take in a function with additional parameters', function () {
const spy = sinon.spy();
Blockly.dialog.setConfirm(spy);
const callback = () => {};
Blockly.dialog.confirm('message', callback, 'extra parameter');
chai.assert.isTrue(
spy.calledWith('message', callback, 'extra parameter'),
);
});
});
suite('Alert', function () {
test('setAlert can take in a function with additional parameters', function () {
const spy = sinon.spy();
Blockly.dialog.setAlert(spy);
const callback = () => {};
Blockly.dialog.alert('message', callback, 'extra parameter');
chai.assert.isTrue(
spy.calledWith('message', callback, 'extra parameter'),
);
});
});
});