mirror of
https://github.com/google/blockly.git
synced 2026-01-08 09:30:06 +01:00
Fix getBlockById unit test. Issue #323
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Blockly Tests
|
||||
*
|
||||
* Copyright 2015 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
function test_getBlockById() {
|
||||
var workspace = new Blockly.Workspace();
|
||||
var blockA = workspace.newBlock('');
|
||||
var blockB = workspace.newBlock('');
|
||||
assertEquals('Find blockA.', blockA, Blockly.Block.getById(blockA.id));
|
||||
assertEquals('Find blockB.', blockB, Blockly.Block.getById(blockB.id));
|
||||
assertEquals('No block found.', null,
|
||||
Blockly.Block.getById('I do not exist.'));
|
||||
blockA.dispose();
|
||||
assertEquals('Can\'t find blockA.', null, Blockly.Block.getById(blockA.id));
|
||||
assertEquals('BlockB exists.', blockB, Blockly.Block.getById(blockB.id));
|
||||
workspace.clear();
|
||||
assertEquals('Can\'t find blockB.', null, Blockly.Block.getById(blockB.id));
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
</head>
|
||||
<body>
|
||||
<script src="blockly_test.js"></script>
|
||||
<script src="block_test.js"></script>
|
||||
<script src="connection_test.js"></script>
|
||||
<script src="connection_db_test.js"></script>
|
||||
<script src="generator_test.js"></script>
|
||||
|
||||
@@ -82,3 +82,18 @@ function test_getWorkspaceById() {
|
||||
assertEquals('WorkspaceB exists.', workspaceB,
|
||||
Blockly.Workspace.getById(workspaceB.id));
|
||||
}
|
||||
|
||||
function test_getBlockById() {
|
||||
var workspace = new Blockly.Workspace();
|
||||
var blockA = workspace.newBlock('');
|
||||
var blockB = workspace.newBlock('');
|
||||
assertEquals('Find blockA.', blockA, workspace.getBlockById(blockA.id));
|
||||
assertEquals('Find blockB.', blockB, workspace.getBlockById(blockB.id));
|
||||
assertEquals('No block found.', null,
|
||||
workspace.getBlockById('I do not exist.'));
|
||||
blockA.dispose();
|
||||
assertEquals('Can\'t find blockA.', null, workspace.getBlockById(blockA.id));
|
||||
assertEquals('BlockB exists.', blockB, workspace.getBlockById(blockB.id));
|
||||
workspace.clear();
|
||||
assertEquals('Can\'t find blockB.', null, workspace.getBlockById(blockB.id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user