mirror of
https://github.com/google/blockly.git
synced 2026-01-06 08:30:13 +01:00
* 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
59 lines
1.4 KiB
JavaScript
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'),
|
|
);
|
|
});
|
|
});
|
|
});
|