mirror of
https://github.com/google/blockly.git
synced 2026-01-07 17:10:11 +01:00
* chore: change goog.module to goog.declareModuleId * chore: change test helper exports to esmod exports * chore: change test helpers to use esmodule imports * chore: convert imports of test helpers to esmodule imports * chore: convert other imports in tests to esm imports * fix: make imports use built files * chore: add blockly imports to a bunch of tests * fix: reference Blockly.Blocks instead of Blocks' * fix: properly import generators * chore: fix lint * chore: cleanup from rebase * chore: cleanup from rebase * chore: fix blocks tests
65 lines
1.9 KiB
JavaScript
65 lines
1.9 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.declareModuleId('Blockly.test.variableModel');
|
|
|
|
import {sharedTestSetup, sharedTestTeardown} from './test_helpers/setup_teardown.js';
|
|
|
|
|
|
suite('Variable Model', function() {
|
|
setup(function() {
|
|
sharedTestSetup.call(this);
|
|
this.workspace = new Blockly.Workspace();
|
|
});
|
|
|
|
teardown(function() {
|
|
sharedTestTeardown.call(this);
|
|
});
|
|
|
|
test('Trivial', function() {
|
|
const variable = new Blockly.VariableModel(
|
|
this.workspace, 'test', 'test_type', 'test_id');
|
|
chai.assert.equal(variable.name, 'test');
|
|
chai.assert.equal(variable.type, 'test_type');
|
|
chai.assert.equal(variable.id_, 'test_id');
|
|
});
|
|
|
|
test('Null type', function() {
|
|
const variable = new Blockly.VariableModel(
|
|
this.workspace, 'test', null, 'test_id');
|
|
chai.assert.equal(variable.type, '');
|
|
});
|
|
|
|
test('Undefined type', function() {
|
|
const variable = new Blockly.VariableModel(
|
|
this.workspace, 'test', undefined, 'test_id');
|
|
chai.assert.equal(variable.type, '');
|
|
});
|
|
|
|
test('Null id', function() {
|
|
const variable = new Blockly.VariableModel(
|
|
this.workspace, 'test', 'test_type', null);
|
|
chai.assert.equal(variable.name, 'test');
|
|
chai.assert.equal(variable.type, 'test_type');
|
|
chai.assert.exists(variable.id_);
|
|
});
|
|
|
|
test('Undefined id', function() {
|
|
const variable = new Blockly.VariableModel(
|
|
this.workspace, 'test', 'test_type', undefined);
|
|
chai.assert.equal(variable.name, 'test');
|
|
chai.assert.equal(variable.type, 'test_type');
|
|
chai.assert.exists(variable.id_);
|
|
});
|
|
|
|
test('Only name provided', function() {
|
|
const variable = new Blockly.VariableModel(this.workspace, 'test');
|
|
chai.assert.equal(variable.name, 'test');
|
|
chai.assert.equal(variable.type, '');
|
|
chai.assert.exists(variable.id_);
|
|
});
|
|
});
|