mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
* Use goog.module in mocha tests * Fix compiler warnings * Make test helpers a module * Name test modules Blockly.test.* This is to be more consistent with how non-test modules are named. Also remove top-level goog.require of TestHelpers (now Blockly.test.helpers) since requiring a side-effect-less module does nothing. * Convert block_test.js and comment_test.js to goog.module syntax * Address PR comments * Goog modulify tests * Goog modulify toolbox helpers * Fixes imports and moves common tests from workspace_test.js to a helper file. * Update test deps after rebase Co-authored-by: Christopher Allen <cpcallen+git@google.com>
65 lines
1.8 KiB
JavaScript
65 lines
1.8 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');
|
|
|
|
|
|
suite('Variable Model', function() {
|
|
setup(function() {
|
|
sharedTestSetup.call(this);
|
|
this.workspace = new Blockly.Workspace();
|
|
});
|
|
|
|
teardown(function() {
|
|
sharedTestTeardown.call(this);
|
|
});
|
|
|
|
test('Trivial', function() {
|
|
var 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() {
|
|
var variable = new Blockly.VariableModel(
|
|
this.workspace, 'test', null, 'test_id');
|
|
chai.assert.equal(variable.type, '');
|
|
});
|
|
|
|
test('Undefined type', function() {
|
|
var variable = new Blockly.VariableModel(
|
|
this.workspace, 'test', undefined, 'test_id');
|
|
chai.assert.equal(variable.type, '');
|
|
});
|
|
|
|
test('Null id', function() {
|
|
var 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() {
|
|
var 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() {
|
|
var variable = new Blockly.VariableModel(this.workspace, 'test');
|
|
chai.assert.equal(variable.name, 'test');
|
|
chai.assert.equal(variable.type, '');
|
|
chai.assert.exists(variable.id_);
|
|
});
|
|
});
|