mirror of
https://github.com/google/blockly.git
synced 2026-01-08 09:30:06 +01:00
* chore: add and configure prettier * chore: remove clang-format * chore: remove clang-format config * chore: lint additional ts files * chore: fix lint errors in blocks * chore: add prettier-ignore where needed * chore: ignore js blocks when formatting * chore: fix playground html syntax * chore: fix yaml spacing from merge * chore: convert text blocks to use arrow functions * chore: format everything with prettier * chore: fix lint unused imports in blocks
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {
|
|
sharedTestSetup,
|
|
sharedTestTeardown,
|
|
} from './test_helpers/setup_teardown.js';
|
|
import {
|
|
assertEventFiredShallow,
|
|
assertEventNotFired,
|
|
createChangeListenerSpy,
|
|
} from './test_helpers/events.js';
|
|
import {MockProcedureModel} from './test_helpers/procedures.js';
|
|
|
|
goog.declareModuleId('Blockly.test.procedureMap');
|
|
|
|
suite('Procedure Map', function () {
|
|
setup(function () {
|
|
sharedTestSetup.call(this);
|
|
this.workspace = new Blockly.Workspace();
|
|
this.procedureMap = this.workspace.getProcedureMap();
|
|
});
|
|
|
|
teardown(function () {
|
|
sharedTestTeardown.call(this);
|
|
});
|
|
|
|
suite('publishing', function () {
|
|
test('inserting a procedure tells it to start publishing', function () {
|
|
const procedureModel = new MockProcedureModel();
|
|
const spy = sinon.spy(procedureModel, 'startPublishing');
|
|
this.procedureMap.set(procedureModel.getId(), procedureModel);
|
|
|
|
chai.assert.isTrue(spy.called, 'Expected the model to start publishing');
|
|
});
|
|
|
|
test('adding a procedure tells it to start publishing', function () {
|
|
const procedureModel = new MockProcedureModel();
|
|
const spy = sinon.spy(procedureModel, 'startPublishing');
|
|
this.procedureMap.add(procedureModel);
|
|
|
|
chai.assert.isTrue(spy.called, 'Expected the model to start publishing');
|
|
});
|
|
|
|
test('deleting a procedure tells it to stop publishing', function () {
|
|
const procedureModel = new MockProcedureModel();
|
|
const spy = sinon.spy(procedureModel, 'stopPublishing');
|
|
this.procedureMap.add(procedureModel);
|
|
|
|
this.procedureMap.delete(procedureModel.getId());
|
|
|
|
chai.assert.isTrue(spy.calledOnce, 'Expected the model stop publishing');
|
|
});
|
|
});
|
|
});
|