Files
blockly/tests/mocha/variable_model_test.js
dependabot[bot] 8873e5fe7a chore(deps): bump chai from 5.2.1 to 6.0.1 (#9330)
* chore(deps): bump chai from 5.2.1 to 6.0.1

Bumps [chai](https://github.com/chaijs/chai) from 5.2.1 to 6.0.1.
- [Release notes](https://github.com/chaijs/chai/releases)
- [Changelog](https://github.com/chaijs/chai/blob/main/History.md)
- [Commits](https://github.com/chaijs/chai/compare/v5.2.1...v6.0.1)

---
updated-dependencies:
- dependency-name: chai
  dependency-version: 6.0.1
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix: Fix Chai import path.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Aaron Dodson <adodson@google.com>
2025-08-26 09:08:01 -07:00

86 lines
2.0 KiB
JavaScript

/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {assert} from '../../node_modules/chai/index.js';
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',
);
assert.equal(variable.getName(), 'test');
assert.equal(variable.getType(), 'test_type');
assert.equal(variable.getId(), 'test_id');
});
test('Null type', function () {
const variable = new Blockly.VariableModel(
this.workspace,
'test',
null,
'test_id',
);
assert.equal(variable.getType(), '');
});
test('Undefined type', function () {
const variable = new Blockly.VariableModel(
this.workspace,
'test',
undefined,
'test_id',
);
assert.equal(variable.getType(), '');
});
test('Null id', function () {
const variable = new Blockly.VariableModel(
this.workspace,
'test',
'test_type',
null,
);
assert.equal(variable.getName(), 'test');
assert.equal(variable.getType(), 'test_type');
assert.exists(variable.getId());
});
test('Undefined id', function () {
const variable = new Blockly.VariableModel(
this.workspace,
'test',
'test_type',
undefined,
);
assert.equal(variable.getName(), 'test');
assert.equal(variable.getType(), 'test_type');
assert.exists(variable.getId());
});
test('Only name provided', function () {
const variable = new Blockly.VariableModel(this.workspace, 'test');
assert.equal(variable.getName(), 'test');
assert.equal(variable.getType(), '');
assert.exists(variable.getId());
});
});