mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
* fix: move core test helpers into new directory * fix: add test helpers to core and convert to goog modules * fix: change tests to use local helpers * fix: change local tests to use chai asserts * fix: skip field tests in serializer b/c test blocks are unavailable * fix: rename some helper files * fix: rename some helper modules * fix: split block helpers into code gen and serialization * fix: split block defs into new helper file * fix: split warning helpers into new file * fix: split user input helpers into new file * fix: split event helpers into a new file * fix: split variable helper into new file * fix: move remaining test helpers to new setup-teardown file * fix: rename setup and teardown module * fix: cleanup from rebase * fix: undo accidental rename * fix: lint? * fix: bad toolbox definitions namespace * fix: fixup warning helpers * fix: remove inclusion of dev-tools in mocha tests * move to modules, but break mocha * fix: run mocha as a module * fix: lint
65 lines
1.9 KiB
JavaScript
65 lines
1.9 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.module('Blockly.test.variableModel');
|
|
|
|
const {sharedTestSetup, sharedTestTeardown} = goog.require('Blockly.test.helpers.setupTeardown');
|
|
|
|
|
|
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_);
|
|
});
|
|
});
|